Posts

#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #include <sys/time.h> #include <arpa/inet.h> #include <string.h> #include <time.h> int main() {     int server_sockfd, client_sockfd;     int server_len, client_len;     char msg1[100];     time_t t;     struct sockaddr_in server_address, client_address;     // Create a TCP socket     server_sockfd = socket(AF_INET, SOCK_STREAM, 0);     if (server_sockfd < 0) {         perror("Error in socket creation");         return 1;     }     // Initialize server address struct     server_address.sin_family = AF_INET;     server_address.sin_port = htons(4006); // Convert port to network byte order     server_address.sin_addr.s_addr = htonl(INADDR_ANY);     server_len = sizeof(server_ad...

70) The courier manager wants to find the details of the courier whose cost is greater than the average cost of the courier in that branch. Write a query to display courier details like courier id, to address and weight of the couriers. Sort the results based on the to address in ascending and weight in ascending order.

Image
 

69) The courier manager decides to create a new courier code for the courier which was booked after '31-03-2020'. The courier code should be created by adding the first three letters of the from address, followed by the first two letters of the courier id and the first three letters of the to address. The courier code should be in upper case. Write a query to display courier details like courier id, branch id and courier code. Give an alias name for the courier code as 'COURIER_CODE'. Sort the results based on the booking date in ascending order.

Image
 

68) Write a query to display the branch id, courier id,from address,to address, weight and cost of the courier where the booking date is same as the expected delivery date. Sort the results based on the branch id in ascending order.

Image
 

67) Write a single query to update the courier's cost based on the following conditions: If the weight of the courier is less than 5 kg, then increase the cost by 5%. If the weight of the courier is greater than or equal to 5 kg and less than or equal to 10 kg, then increase the cost by 10%. If the weight of the courier is greater than 10 kg, then increase the cost by 15%.

Image
 

66) Write a query to change the data type from varchar2(20) to varchar2(30) and also add a not null constraint for the column branch_location in the branch table.

Image
 

65) Refer to the given schema. Write a query to create a courier table with the constraints mentioned. Assume that the branch table and customer table are already created.

Image