Packing Labels
Part of the First Queries section of Coddy's PostgreSQL journey. Lesson 15 of 20.
Challenge
MediumReturn id, label and stock_value for in-stock products. label is the note when present or Standard pack when missing; stock_value is price times stock. Order by stock_value descending, then id.
The input tables are shown in the test panel. Each run starts from fresh data. Return the named columns in the stated order; do not hard-code the displayed rows.
Try it yourself
-- Write your SQL here.
All lessons in First Queries
3Build Useful Results
Calculate and Name ColumnsUnique Results with DISTINCTLabels with CASEFallbacks with COALESCEPacking LabelsPractice on your own: PostgreSQL playground