Advertisement
Mary_99

lab3

Oct 16th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.91 KB | None | 0 0
  1. --SELECT * FROM tutors
  2. --SELECT name, last_name
  3. --FROM students
  4. --WHERE city  = 'Lodz'
  5.  
  6. --SELECT  last_name
  7. --FROM students
  8. --WHERE zip_code = 12345
  9.  
  10. -- Get subjects names with an id number less than 2 and greater than 5. Use
  11.  
  12. --SELECT subject_name , subject_id
  13. --FROM subjects
  14. --WHERE  subject_id <2 OR subject_id  >5
  15.  
  16. -- Get the students numbers for all students that were born in Elsene or Los Angeles  (or both).
  17.  
  18. --SELECT name , birth_place
  19. --FROM students
  20. --WHERE  birth_place IN ( 'Elsene' ,'Los Angeles')
  21.  
  22. -- Get the students numbers for all students that were born in Lodz and residing in
  23. --Lodz or were born earlier than 1950. Use comparison operators.
  24.  
  25.  
  26. --SELECT student_id, name , birth_place, birth_date ,city
  27. --FROM students
  28. --WHERE ( birth_place IN ( 'lodz') AND city IN('lodz')) OR DATEPART (YEAR, birth_date ) < 1950
  29.  
  30.  --Get names of the birth_places for all students.
  31.  
  32. --SELECT student_id, name , birth_place
  33. --FROM students
  34.  
  35. -- Get students numbers and names of all students who do not live in Lodz.
  36.  
  37. --SELECT student_id, name ,city
  38. --FROM students
  39. --WHERE city NOT IN ( 'lodz')
  40.  
  41. --Get all the columns for every student whose zip_code number equals 12345, 22345 or 32445
  42.  
  43. --SELECT student_id, name ,zip_code
  44. --FROM students
  45. --WHERE zip_code IN ( 12345, 223445, 32445)
  46.  
  47.  
  48. --SELECT student_id, name ,zip_code
  49. --FROM students
  50. --WHERE zip_code NOT IN (12345, 223445, 32445)
  51.  
  52. -- Get students numbers for all students that were born earlier than 1950 and later than 1940. Use the BETWEEN operator.
  53.  
  54. --SELECT student_id, name ,birth_date
  55. --FROM students
  56. --WHERE DATEPART (YEAR, birth_date ) BETWEEN 1940 AND 1950
  57.  
  58. --SELECT student_id, name ,birth_date
  59. --FROM students
  60. --WHERE DATEPART (YEAR, birth_date ) NOT BETWEEN 1940 AND 1950
  61.  
  62. -- Get students numbers for all students residing in Lodz and which fax column is null.
  63.  
  64. --SELECT student_id, name , city , fax
  65. --FROM students
  66. --WHERE ( city  IN ( 'lodz')) OR fax IS  NULL
  67.  
  68. -- Get students numbers for all students whose registration_date column is not null
  69.  
  70. --SELECT student_id, name ,registration_date
  71. --FROM students
  72. --WHERE registration_date IS NOT NULL
  73.  
  74. --Get the first and last names and numbers of all students whose first name contains the letter 'a' as the second character.
  75.  
  76. --SELECT  student_id, name, last_name
  77. --FROM students
  78. --WHERE name LIKE '_a%'
  79.  
  80. --Get full details of all students whose name begins with a character in the range C through W
  81.  
  82. --SELECT * FROM students
  83. --WHERE name LIKE '[c-w]%'
  84.  
  85. -- Get full details of all students whose last name does not begin with the letter J, K,L, M, N, or O
  86. --and whose first name does not begin with the letter E or Z
  87.  
  88. --SELECT * FROM students
  89. --WHERE last_name NOT  LIKE '[JKLMNO]%' AND name  NOT  LIKE '[EZ]%'
  90.  
  91. --Get full details of all students whose name does not end with the 'n' character.
  92.  
  93. --SELECT * FROM students
  94. --WHERE name NOT  LIKE '%n'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement