﻿ AdventureWorks: Retrieve only the rows for product

# AdventureWorks Database: Retrieve only the rows for product

## SQL Query - AdventureWorks: Exercise-4 with Solution

4. From the following table write a query in SQL to return only the rows for product that have a sellstartdate that is not NULL and a productline of 'T'. Return productid, productnumber, and name. Arranged the output in ascending order on name.

Sample table: production.product

Click to view Full table

Sample Solution:

SELECT productid, productnumber, name as producName
FROM production.product
WHERE sellstartdate IS NOT NULL
AND production.product.productline= 'T'
ORDER BY name;

Sample Output:

productid|productnumber|producname                   |
---------+-------------+-----------------------------+
890|FR-T98U-46   |HL Touring Frame - Blue, 46  |
891|FR-T98U-50   |HL Touring Frame - Blue, 50  |
892|FR-T98U-54   |HL Touring Frame - Blue, 54  |
893|FR-T98U-60   |HL Touring Frame - Blue, 60  |
887|FR-T98Y-46   |HL Touring Frame - Yellow, 46|
888|FR-T98Y-50   |HL Touring Frame - Yellow, 50|
889|FR-T98Y-54   |HL Touring Frame - Yellow, 54|
885|FR-T98Y-60   |HL Touring Frame - Yellow, 60|
947|HB-T928      |HL Touring Handlebars        |
903|FR-T67U-44   |LL Touring Frame - Blue, 44  |
895|FR-T67U-50   |LL Touring Frame - Blue, 50  |
896|FR-T67U-54   |LL Touring Frame - Blue, 54  |
897|FR-T67U-58   |LL Touring Frame - Blue, 58  |
...

## Practice Online

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿