Professional Documents
Culture Documents
Original SQL TEST 2018
Original SQL TEST 2018
You are to write SQL statements to answer the following questions, using the 2 tables user_tab and order_tab. Sample data is p
You may use the internet for help.
Questions:
1) Write an SQL statement to count the number of users per country (5 marks)
Answer:
SELECT country, COUNT(*) FROM user_tab GROUP BY country
2) Write an SQL statement to count the number of orders per country (10 marks)
Answer:
SELECT country FROM user_tab INNER JOIN order_tab ON userid =userid, COUNT(*) FROM user_tab GROUP BY country
3) Write an SQL statement to find the first order date of each user (10 marks)
Answer:
SELECT userid, MIN(order_time) AS order_time FROM order_tab GROUP BY userid
4) Write an SQL statement to find the number of users who made their first order in each country, each day (25 marks)
Answer:
5) Write an SQL statement to find the first order GMV of each user. If there is a tie, use the order with the lower orderid (30 ma
Answer:
6) Find out what is wrong with the sample data (20 marks)
Answer:
register_date and order_time not in sync
and order_tab. Sample data is present in the respectively named sheets. (100 marks)