-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuery.sql
25 lines (21 loc) · 809 Bytes
/
Query.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- Return orders placed on June 2007
/* SELECT orderid, orderdate, custid, empid
FROM Sales.Orders
WHERE orderdate BETWEEN '2007/06/01' AND '2007/07/01'; */
-- Return orders placed on the last day of the month
/* SELECT orderid, orderdate, custid, empid
FROM Sales.Orders
WHERE orderdate = EOMONTH(orderdate) */
-- Return employees with last name containing the letter 'a' twice or more
/* SELECT empid, firstname, lastname
FROM HR.Employees
WHERE LEN(lastname)-LEN(REPLACE(lastname,'a','')) >= 2; */
-- 4
-- Return orders with total value(qty*unitprice) greater than 10000
-- sorted by total value
-- Tables involved: Sales.OrderDetails table
/* SELECT orderid, SUM(unitprice*qty) AS totalvalue
FROM Sales.OrderDetails
GROUP BY orderid
HAVING SUM(unitprice*qty) >= 10000
ORDER BY totalvalue DESC; */