SQL Flow Field Guide

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

  1. Read the VALUES rows and the column names assigned to them.
  2. Follow ItemName and OnHand into the SELECT list.
  3. 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 Flow
SELECT 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