Ch05 SQL Supp
Ch05 SQL Supp
Output:
ProductID ProductDescription ProductStandardPrice
1 End Table $175
2 Coffee Table $200
8 Computer Desk $250
Figure-1 - Sample Pine Valley Furniture Company data Slide
3
Slide
4
Slide
6
Slide
7
Slide
9
Slide
17
Slide
18
Slide 23
Slide 24
Slide 25
Which orders have been placed since 10/24/2010?(Refer to Figure-1)
Output:
OrderID OrderDate
1007 10/27/2010
1008 10/30/2010
1009 11/05/2010
1010 11/05/2010
Which furniture does Pine Valley carry that isn’t made of cherry?(Refer to
Figure-1)
Output:
ProductDescription ProductFinish
Customer Table
Output:
CustomerID CustomerName LastName Country Age Phone
2 Aman Chopra Australia 21 XXXXXX
Which products in the Product table have a standard price between
$200 and $300? (Refer to Figure-1)
Output:
ProductDescription ProductStandardPrice
Coffee Table 200
Computer Desk 250
List product name, finish, and standard price for all desks and all tables
that cost more than $300 in the Product table. (Refer to Figure-1)
ProductDescription ProductFinish
ProductStandardPrice
ProductDescription ProductFinish
ProductStandardPrice
UPDATE Employee
SET Age = Age + 5, Salary = Salary + 3000;
Employee Table
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 Kaushik 23 Kota 2500.00
Output:
ID NAME AGE ADDRESS SALARY
1 Ramesh 37 Ahmedabad 5000.00
2 Khilan 30 Delhi 4500.00
3 Kaushik 28 Kota 5500.00
What is the employee name whose salary is smaller than or equal to
$1,500 in the Employee table?
Output:
EmployeeName Salary
Khilan 1500
Identify(count) the number of customers whose country is the UK.
SELECT Count(country)
FROM Customer
WHERE country = ‘UK’;
Customer table
CustomerID FirstName LastName Age Country
1 John Joe 31 USA
2 Robert Luna 22 USA
3 David Robinson 22 UK
4 John Reinhardt 25 UK
5 Betty Doe 28 UAE
Output:
COUNT(country)
2
Figure-2 - Sample Pine Valley Furniture Company
data
Order_T Customer_T
Slide 1
5
Slide 2
2
Count the number of customers in each state to which we ship. (Refer to Figure-2)
Output:
CustomerState Count(CustomerState)
CA 2
CO 1
FL 3
HI 1
MI 1
NJ 2
NY 1
PA 1
TX 1
UT 1
WA 1
Display for each employee the difference between salary and the overall
salary(average salary).
Employee table
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 Kaushik 23 Kota 2500.00
Output:
Salary AvgSalary Difference
2,000 2,000 0
1,500 2,000 -500
2,500 2,000 500
List all customers who live in warmer states. (Refer to Figure-1)
Output:
Output:
Output:
Average Marks>90
96
Based on the details of the student table, calculate the
average student marks by course.
Output:
Course AVG(Marks)
BBA 78
BCA 97
MBA 84
MCA 93
Tech 91
List and display CustomerID, CustomerName and
CustomerPostalCode for those customers who live in
California(CA) or Washington(WA), order by
CustomerPostalCode in descending order. (
Refer to Figure-2)
FROM Order_T
GROUP BY CustomerID;