Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SELECT * FROM tutors
- --SELECT name, last_name
- --FROM students
- --WHERE city = 'Lodz'
- --SELECT last_name
- --FROM students
- --WHERE zip_code = 12345
- -- Get subjects names with an id number less than 2 and greater than 5. Use
- --SELECT subject_name , subject_id
- --FROM subjects
- --WHERE subject_id <2 OR subject_id >5
- -- Get the students numbers for all students that were born in Elsene or Los Angeles (or both).
- --SELECT name , birth_place
- --FROM students
- --WHERE birth_place IN ( 'Elsene' ,'Los Angeles')
- -- Get the students numbers for all students that were born in Lodz and residing in
- --Lodz or were born earlier than 1950. Use comparison operators.
- --SELECT student_id, name , birth_place, birth_date ,city
- --FROM students
- --WHERE ( birth_place IN ( 'lodz') AND city IN('lodz')) OR DATEPART (YEAR, birth_date ) < 1950
- --Get names of the birth_places for all students.
- --SELECT student_id, name , birth_place
- --FROM students
- -- Get students numbers and names of all students who do not live in Lodz.
- --SELECT student_id, name ,city
- --FROM students
- --WHERE city NOT IN ( 'lodz')
- --Get all the columns for every student whose zip_code number equals 12345, 22345 or 32445
- --SELECT student_id, name ,zip_code
- --FROM students
- --WHERE zip_code IN ( 12345, 223445, 32445)
- --SELECT student_id, name ,zip_code
- --FROM students
- --WHERE zip_code NOT IN (12345, 223445, 32445)
- -- Get students numbers for all students that were born earlier than 1950 and later than 1940. Use the BETWEEN operator.
- --SELECT student_id, name ,birth_date
- --FROM students
- --WHERE DATEPART (YEAR, birth_date ) BETWEEN 1940 AND 1950
- --SELECT student_id, name ,birth_date
- --FROM students
- --WHERE DATEPART (YEAR, birth_date ) NOT BETWEEN 1940 AND 1950
- -- Get students numbers for all students residing in Lodz and which fax column is null.
- --SELECT student_id, name , city , fax
- --FROM students
- --WHERE ( city IN ( 'lodz')) OR fax IS NULL
- -- Get students numbers for all students whose registration_date column is not null
- --SELECT student_id, name ,registration_date
- --FROM students
- --WHERE registration_date IS NOT NULL
- --Get the first and last names and numbers of all students whose first name contains the letter 'a' as the second character.
- --SELECT student_id, name, last_name
- --FROM students
- --WHERE name LIKE '_a%'
- --Get full details of all students whose name begins with a character in the range C through W
- --SELECT * FROM students
- --WHERE name LIKE '[c-w]%'
- -- Get full details of all students whose last name does not begin with the letter J, K,L, M, N, or O
- --and whose first name does not begin with the letter E or Z
- --SELECT * FROM students
- --WHERE last_name NOT LIKE '[JKLMNO]%' AND name NOT LIKE '[EZ]%'
- --Get full details of all students whose name does not end with the 'n' character.
- --SELECT * FROM students
- --WHERE name NOT LIKE '%n'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement