Questions
Questions
Summary of Data
Please make sure that SQL code are error free and executable. The expectation is that every query
should return data.
1) Design a SQL code that gives a new column which will identify every delivery by its fill type.
(Out of gas, Zero Fill, Inefficient, Regular Fill)
For example, if Fill % = 50, then the new column should have a value as “Regular Fill”
2) Design a SQL code that returns Max, Min & Average Fill % by CSC. Please round the overall
result to 2 decimal places and sort the results by decreasing order of average values.
3) Design a SQL code that returns the Delivery Date, Units Delivered, Tank Useable Size & Fill %
for all “Out of Gas” deliveries belonging to CSC= “1550 Marlboro, NY”
4) This table has duplicate entries. Design a SQL code that returns all duplicate rows all with
their counts.
5) Design a SQL code that will delete all duplicate entries with a single query and no
intermediate table. Please mention counts before the delete query, count of duplicate rows,
and counts after execution of delete query.
6) Design a SQL code that will return all Regions and their Products with total sales > $52,000
7) Design a SQL code that will return the product with 3rd highest margin for every CSC.
Margin can be calculated at a delivery level (product sale amount – product cost)
8) Design a SQL code that will return the CSC with the 5th highest margin
9) In the column “CSC”, the last 2 characters are the initials for the State the CSC belongs.
Write a SQL query that will extract the STATE initials from the field CSC.
For example: 1280 Rome, NY will have NY as the output of above query.
10) With data in the below table, swap all NBC and CBS values (i.e., change all NBC values to CBS
and vice versa) with a single update query and no intermediate temp table.