Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from customers;
- select
- country,count(*) as total
- from customers group by country
- order by total desc;
- select * from employees;
- select title,count(*) as total
- from employees
- group by title
- order by total desc;
- select * from products;
- select categoryname,count(*) as total
- from products p join Categories c
- on p.CategoryID=c.CategoryID
- group by categoryname
- order by total desc;
- select * from orders;
- select
- year(orderdate) as yearr,
- month(orderdate) as monthh,
- count(*)as totalorders,
- sum(unitprice*quantity) as totalsales
- from orders o
- join orderdetails od
- on o.OrderID=od.OrderID
- group by
- year(orderdate),
- month(orderdate)
- order by yearr asc,monthh asc
- select
- productname,
- year(orderdate) as yearr,
- month(orderdate) as monthh,
- count(*)as totalorders,
- sum(od.unitprice*quantity) as totalsales
- from orders o
- join orderdetails od
- on o.OrderID=od.OrderID
- join products p
- on od.ProductID=p.ProductID
- group by
- productname,
- year(orderdate),
- month(orderdate)
- order by productname asc, yearr asc,monthh asc
- select
- companyname,
- year(orderdate) as yearr,
- month(orderdate) as monthh,
- count(*)as totalorders,
- sum(unitprice*quantity) as totalsales
- from orders o
- join orderdetails od
- on o.OrderID=od.OrderID
- join customers c
- on o.CustomerID=c.CustomerID
- group by
- companyname,
- year(orderdate),
- month(orderdate)
- order by companyname,yearr asc,monthh asc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement