Professional Documents
Culture Documents
21SJCCC025
21SJCCC025
21SJCCC025
Query:
show databases;
use super_market;
show tables;
select * from super_market.branches limit 8;
select * from super_market.transactions limit 8;
Solution:
Qn-5 get the total number of transactions with price range of 900 and 1000
Hint: use between
select count(*) from super_market.transactions where Price between 900 and 1000;
Qn-6 get the transaction details for the price 999 and branch id 66
select * from super_market.transactions where Price =999 and Branch_ID =66;
Qn-7 identify the branch name, location, address and manager name of the above result
select * from super_market.branches where Branch_ID=66;
Qn-8 get the transaction details of the purchases happened on 02 nd May 2022
select * from super_market.transactions where Purchase_Date = '2022-05-02';
Qn-9 get the total number of transactions happened between 01 st Jan 2020 and 31st Jan 2020
select count(*) from super_market.transactions where Purchase_Date between '2020-01-01' and
'2022-01-31';
Solution-
Solution-
4. Identify best 5 branches of the supermarket based upon the total price
Select Branch_ID, sum(price) as Total_Price from super_market.transactions group by Branch_ID
order by Total_Price Desc limit 5
5.Identify the best 5 branches of the supermarket based upon the total no. of transactions.
Select Branch_ID, count(*) as 'Total_number_of_transactions' from super_market.transactions
group by Branch_ID order by Total_number_of_transactions Desc limit 5;