[{"id":"sqlserverbeginner-001","courseId":"sql-server-beginner","domain":"querying","topic":"SELECT and FROM basics","prompt":"A SELECT statement uses the clauses FROM, WHERE, GROUP BY, HAVING and SELECT. Put these clauses in the order the query processor logically applies them.","hint":"Think about where the rows come from before anything is shaped for output.","explain":"Statements are worked out in a fixed series of stages, not in the order their text is typed. Each stage only uses what earlier stages have already produced, so ask what each part needs before it can act.","source":"https://learn.microsoft.com/en-us/sql/t-sql/queries/select-transact-sql","interaction":{"type":"sort","items":[{"text":"FROM","why":"Names the source tables, so the rows exist before any other clause can act on them."},{"text":"WHERE","why":"Filters individual rows before any grouping happens."},{"text":"GROUP BY","why":"Builds groups from the rows that passed WHERE."},{"text":"HAVING","why":"Filters whole groups, so it has to run after GROUP BY has made them."},{"text":"SELECT","why":"Shapes the output columns; it is step 8, so aliases it defines are not visible to earlier clauses."}]},"options":[],"answer":"o:abcde","explanation":"The SELECT statement has a logical processing order: FROM binds the tables first, the row filter and grouping come next, and the SELECT list is processed later, so its aliases can't be used in WHERE.","concept":"The SELECT statement has a logical processing order: FROM binds the tables first, the row filter and grouping come next, and the SELECT list is processed later, so its aliases can't be used in WHERE.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Column aliases from SELECT can't be used in WHERE, because WHERE is processed earlier."]},{"id":"sqlserverbeginner-002","courseId":"sql-server-beginner","domain":"querying","topic":"WHERE row filtering","prompt":"A query on DimEmployee must return only the rows whose EmployeeKey is 500 or less. Which clause should hold that row condition?","hint":"Think about which clause tests each row against a condition.","explain":"A query can return every row of a table or only the rows that pass a yes-or-no test. A search condition is that test, and a row comes back only when the test holds for it.","source":"https://learn.microsoft.com/en-us/sql/t-sql/queries/where-transact-sql","interaction":{"type":"single"},"options":[{"id":"a","text":"WHERE EmployeeKey <= 500","why":"WHERE specifies the search condition that the rows returned by the query must meet."},{"id":"b","text":"HAVING EmployeeKey <= 500","whyNot":"HAVING filters after rows are grouped, and this query has no groups to filter."},{"id":"c","text":"ORDER BY EmployeeKey <= 500","whyNot":"ORDER BY arranges the result; it takes sort expressions, not a condition that decides which rows come back."},{"id":"d","text":"SELECT EmployeeKey <= 500","whyNot":"SELECT lists the output and runs after WHERE in logical order, so row filtering has already happened by then."}],"answer":"a","explanation":"The WHERE clause specifies the search condition for the rows a query returns; a row is returned only when the condition is met.","concept":"The WHERE clause specifies the search condition for the rows a query returns; a row is returned only when the condition is met.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Filter individual rows with WHERE; HAVING works on groups, after GROUP BY has formed them."]},{"id":"sqlserverbeginner-003","courseId":"sql-server-beginner","domain":"querying","topic":"ORDER BY sorting","prompt":"A teammate asks how ORDER BY behaves in SQL Server. Which TWO statements about it are correct?","hint":"Think about what the direction keyword changes, and how text values are compared.","explain":"Sorting arranges returned rows by one or more keys, each in a direction you pick. Different kinds of values follow different comparison rules, so the same digits can line up differently as numbers and as characters.","source":"https://learn.microsoft.com/en-us/sql/t-sql/queries/select-order-by-clause-transact-sql","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Adding DESC after a column sorts the result in descending order.","why":"DESC makes the sort run in descending order, as in ORDER BY ProductID DESC."},{"id":"b","text":"A text column sorts alphabetically, so 10 comes before 2.","why":"The characters are sorted alphabetically, not numerically, so 10 sorts before 2."},{"id":"c","text":"ORDER BY works only on numeric columns; text columns can't be sorted.","whyNot":"ORDER BY Name ASC sorts a text column alphabetically, so text columns can be sorted."},{"id":"d","text":"ORDER BY FirstName ASC, LastName DESC sorts by LastName first, then by FirstName.","whyNot":"The first column listed is sorted first: ascending by FirstName, and then descending by LastName."},{"id":"e","text":"ORDER BY rearranges the stored rows, so later queries see the new order.","whyNot":"ORDER BY orders the result set that the query returns; it doesn't change the rows stored in the table."},{"id":"f","text":"A collation can be set only on the column, never inside an ORDER BY.","whyNot":"Specifying a collation in the ORDER BY clause can change the order in which results are returned."}],"answer":"ab","explanation":"ORDER BY orders the result set; DESC sorts in descending order, and a text column sorts alphabetically, so 10 comes before 2.","concept":"ORDER BY orders the result set; DESC sorts in descending order, and a text column sorts alphabetically, so 10 comes before 2.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Text sorts alphabetically, so 10 comes before 2; ORDER BY uses the column's collation."]},{"id":"sqlserverbeginner-004","courseId":"sql-server-beginner","domain":"querying","topic":"TOP row limits","prompt":"Statement: In SQL Server, a query that uses SELECT TOP (5) with no ORDER BY clause returns the first five rows in a defined order.","hint":"Think about which clause decides the order that the limit is applied to.","explain":"A row limit only means something when rows come out in a known sequence. A limit can be applied with or without a sorting clause, and the sequence it works on depends on whether that clause is present.","source":"https://learn.microsoft.com/en-us/sql/t-sql/queries/top-transact-sql","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Without ORDER BY, TOP returns rows in an undefined order, so there is no defined first five."},{"id":"b","text":"False","why":"TOP limits the result to the first n ordered rows only when ORDER BY is present; without it the order is undefined."}],"answer":"b","explanation":"TOP limits results to n rows; with ORDER BY these are the first n ordered rows, but without it TOP returns n rows in an undefined order.","concept":"TOP limits results to n rows; with ORDER BY these are the first n ordered rows, but without it TOP returns n rows in an undefined order.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Always pair TOP with ORDER BY when you need a predictable set of rows."]},{"id":"sqlserverbeginner-005","courseId":"sql-server-beginner","domain":"querying","topic":"NULL in comparisons","prompt":"This query runs against a row whose Phone is NULL. What does the comparison in its WHERE clause return for that row?","hint":"Think about what a comparison gives when one side has no known value.","explain":"NULL marks a missing value, not zero or blank. Comparing such a marker with a real value doesn't give a plain yes or no, and a filter keeps only rows whose test gives a plain yes.","source":"https://learn.microsoft.com/en-us/sql/t-sql/language-elements/null-and-unknown-transact-sql","interaction":{"type":"single"},"options":[{"id":"a","text":"UNKNOWN, which is neither TRUE nor FALSE","why":"A comparison with a null value returns unknown, a third result beside TRUE and FALSE, so the row isn't kept."},{"id":"b","text":"TRUE, because NULL differs from '555-0100'","whyNot":"A comparison with NULL never returns TRUE, because the value of the NULL is unknown."},{"id":"c","text":"FALSE, because a missing value can't equal anything","whyNot":"The result is unknown rather than FALSE; unknown is a separate third result."},{"id":"d","text":"An empty string, which equals the NULL","whyNot":"A null value is different from an empty or zero value, so it doesn't match an empty string."}],"answer":"a","explanation":"Comparing a NULL with any value, even another NULL, returns UNKNOWN, a third result beside TRUE and FALSE; a WHERE clause keeps only rows whose condition is TRUE.","concept":"Comparing a NULL with any value, even another NULL, returns UNKNOWN, a third result beside TRUE and FALSE; a WHERE clause keeps only rows whose condition is TRUE.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","code":"SELECT Phone\nFROM Customer\nWHERE Phone <> '555-0100';","takeaways":["A WHERE clause quietly drops rows whose comparison isn't TRUE; test for missing values with IS NULL."]}]