1. get customerid,totalamt,noOfinstallements for every customer.
customerid,installmentdate,installmentamt
1,2020-01-01,100
1,2020-02-01,150
2,2020-01-01,100
2,2020-02-01,100
2,2020-03-01,100
2,2020-04-01,100
op:
customerid,totalamt,noOfinstallements
1,250,2
2,400,4
Ans.
select custid, sum(installmentamt) as totalamt, count(custid) as noofinstallements from cust_tbl group by custid
2. get latest record for every order_id.
order_id,order_status,order_time
1,Ordered,03-Jan
1,Shipped,05-Jan
2,Ordered,03-Jan
2,Shipped,05-Jan
2,Delivered,10-Jan
op:
1,Shipped,05-Jan
2,Delivered,10-Jan
3. get percentage in a hike for every emp_id
emp_id,emp_name,emp_sal,ts
1,Ravi,100,03-Jan-2018
1,Ravi,120,03-Jan-2019
1,Ravi,140,03-Jan-2020
2,Ram,110,10-Jan-2016
2,Ram,140,10-Jan-2017
2,Ram,160,10-Jan-2018
----------------------------------------------------
1.) Find the count of duplicate rows and delete them.
2.) Find nth highest salary ( preferably using self join concept )
3.) SQL query to calculate nth percentile & quartile ( with and without partition )
4.) How to fetch the common records or alternate records from a table ( concept of intersecting)
5.) Assume an Employee table consists of emp Id, name & manager id, finding the manager name of each employee ( concept of self-join).
6.) There is a table contains students details and marks, listing down the students having marks greater than average ( concept of subquery )
2.) Find nth highest salary ( preferably using self join concept )
3.) SQL query to calculate nth percentile & quartile ( with and without partition )
4.) How to fetch the common records or alternate records from a table ( concept of intersecting)
5.) Assume an Employee table consists of emp Id, name & manager id, finding the manager name of each employee ( concept of self-join).
6.) There is a table contains students details and marks, listing down the students having marks greater than average ( concept of subquery )
0 Comments