MySQL Related Interview Questions

 1)   You have a table of customer order with column for oder_date,customer_id and order_total. You want to find the total order value for each customer,but only for those who have placed orders in the year 2023.what is the correct SQL query 

A) select customer_id,SUM(order_total) FROM orders Where YEAR(order_date)=2023 GROUP BY customer_id

B) select customer_id,SUM(order_total) FROM orders GROUP BY customer_id HAVING YEAR(order_date)=2023

C) select customer_id,SUM(order_total)FROM orders GROUP BY customer_id WHERE YEAR(order_date)=2023

D)select customer_id,SUM(order_total)FROM orders GROUP BY customer_id,YEAR(order_date)=2023

No comments:

Post a Comment

Pages