SQL Data Manipulation 1
SQL Data Manipulation 1
LECTURE 4
SELECT *
FROM Staff;
Dr. Said Mirza Pahlevi Sekolah Tinggi Ilmu Statistik (STIS)
Result of Example 1
15
SELECT propertyNo
FROM Viewing;
2500.00
1000.00
1500.00
750.00
2000.00
7500.00
2500.00
1000.00
1500.00
750.00
2000.00
7500.00
Staff
Branch Result
Staff Result
Result
There are 2 viewings for property PG4, one with and one without a
comment.
Negated version (IS NOT NULL) can test for non-null values.
4. Tampilkan first name dan last name dari semua staff yang berada
pada branch B005 atau B007.
SELECT COUNT(staffNo) AS
myCount,
SUM(salary) AS mySum
FROM Staff
WHERE position = ‘Manager’;
SELECT branchNo,
COUNT(staffNo) AS myCount,
SUM(salary) AS mySum
FROM Staff
GROUP BY branchNo
HAVING COUNT(staffNo) > 1
ORDER BY branchNo;
SELECT type,
COUNT(propertyNo) AS tProperty,
SUM(rent) AS tRent,
SUM(rooms) AS tRoom
FROM propertyForRent
GROUP BY type
ORDER BY type;
SELECT ownerNo,
COUNT(propertyNo) AS tProperty,
SUM(rooms) AS tRoom,
FROM propertyForRent
GROUP BY ownerNo
HAVING COUNT(propertyNo) >= 2 AND SUM(rooms)>8;
List all double or family rooms with a price below £40.00 per
night, in ascending order of price.
List the bookings for which no dateTo has been specified.
What is the average price of a room?
What is the total revenue per night from all double rooms?
List the details of all rooms at the Grosvenor Hotel, including the
name of the guest staying in the room, if the room is occupied.
What is the total income from bookings for the Grosvenor Hotel
today?
What is the average number of bookings for each hotel in
August?
What is the most commonly booked room type for each hotel in
London?