Assign1 Ans
Assign1 Ans
Simple Queries
1. Write a SELECT statement to list course data sorted by course number. (30 rows)
SELECT *
FROM course
ORDER BY course_no
2. Write a SELECT statement to list zipcodes and their cities in New York State sorted by
zipcode. (123 rows)
SELECT
FROM
WHERE
ORDER
zip, city
zipcode
state = 'NY'
BY zip
3. Write a SELECT statement to list first and last names of all instructors sorted by last name.
(10 rows)
SELECT *
FROM course
WHERE prerequisite = 20
5. Write a SELECT statement to list the last and first names in last name order of students that
are currently employed by the firm Electronic Engineers and have last names starting with
"G". (2 rows)
SELECT
FROM
WHERE
AND
ORDER
6. Write the same SELECT statement as #5 but include students who are Electronic Engineers
employees with the last name beginning with S or B. (Hint: Use parentheses in the WHERE
clause to isolate the OR logic). (2 rows)
SELECT
FROM
WHERE
AND
ORDER
7. Write a SELECT statement to list students that live either in zip code 11433, 11434, or 11435.
(5 rows)
SELECT *
FROM student
WHERE zip IN ('11433', '11434', '11435')
8. Write a SELECT statement to list the courses that cost $1095 or less. (3 rows)
SELECT *
FROM course
WHERE cost <= 1095
9. Write a SELECT statement to list the first and last name of students that do not have the
salutation of "Dr.". (267 rows)