All quizzesEasy
SQL Basics — Series 3
Preview — 3 of 10 questions
Both queries below run against the same users table. What's true about them?
javascript
SELECT u.name FROM users AS u;
SELECT u.name FROM users u;AOnly the first is valid SQL; the second is a syntax error
BThey are equivalent — AS is optional when aliasing a table, so users u and users AS u both alias the table to u
CThe second aliases the table to AS, not u
DThey return different columns because aliasing changes which columns are selected
Given rows in employees(department, salary), what order do rows come back in?
javascript
SELECT department, salary FROM employees
ORDER BY department ASC, salary DESC;ASorted by salary first, then department
BSorted by department descending, salary ascending
COnly department is used for sorting; the second column is ignored
DSorted by department alphabetically A→Z, and within each department, by salary from highest to lowest
In PostgreSQL, what is the difference between <> and != as inequality operators?
ANone — they are exact synonyms; PostgreSQL treats != as an alias for <>
B!= is faster because it's evaluated natively while <> is rewritten at parse time
C<> only works on numeric types; != works on all types
D!= is deprecated and will be removed in a future PostgreSQL version
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.