Choose the columns a report needs
Return a clear result with only the requested columns.
What you are trying to do
A stock screen needs each item name and its available quantity.
Work through it
- Read the VALUES rows and the column names assigned to them.
- Follow ItemName and OnHand into the SELECT list.
- Check that both items appear and UnitPrice stays out of the result.
Check your work
The result has two columns and two rows. It shows Clip with 6 and Pen with 3, in item-name order.
Practice SQL
Open in SQL FlowSELECT ItemName AS Item, OnHand
FROM (VALUES (N'Pen', 3, 8), (N'Clip', 6, 24)) AS Stock(ItemName, OnHand, UnitPrice)
ORDER BY ItemName;
Knowledge check
Commands in this lesson
Next lesson Read values with their data types