Created
December 22, 2014 23:19
-
-
Save JubbaSmail/66f781ad861957e6f4dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from orders | |
--========================================== | |
select order_id,order_mode from orders | |
--========================================== | |
select order_id,order_mode from orders | |
where order_total > 7000 | |
--========================================== | |
select count(order_id) from orders | |
--========================================== | |
select count(order_id) from orders | |
where order_total > 15000 | |
--========================================== | |
select max(order_total) from orders | |
--========================================== | |
select min(order_total) from orders | |
--========================================== | |
select order_mode,sum(order_total) from orders | |
group by order_mode | |
--========================================== | |
select order_id from orders | |
where order_total = | |
(select max(order_total) from orders) | |
--========================================== | |
select order_mode from | |
(select order_mode,sum(order_total) as t from orders group by order_mode) | |
where t = (select max( sum(order_total) ) from orders group by order_mode) | |
--========================================== | |
select order_mode from | |
(select order_mode,sum(order_total) as t from orders group by order_mode) | |
where t = (select min( sum(order_total) ) from orders group by order_mode) | |
--========================================== | |
select * | |
from customers | |
--========================================== | |
select CUST_LAST_NAME, CUST_FIRST_NAME | |
from customers | |
--========================================== | |
select CUSTOMER_ID , count(ORDER_ID) as o from orders group by CUSTOMER_ID | |
--========================================== | |
select max(count(ORDER_ID)) from orders group by CUSTOMER_ID | |
--========================================== | |
select CUSTOMER_ID | |
from (select CUSTOMER_ID , count(ORDER_ID) as o from orders group by CUSTOMER_ID) | |
where o = (select max(count(ORDER_ID)) from orders group by CUSTOMER_ID) | |
--========================================== | |
select CUST_LAST_NAME, CUST_FIRST_NAME | |
from customers | |
where customer_id in ( | |
select CUSTOMER_ID | |
from (select CUSTOMER_ID , count(ORDER_ID) as o from orders group by CUSTOMER_ID) | |
where o = (select max(count(ORDER_ID)) from orders group by CUSTOMER_ID) | |
) | |
--========================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment