AdventureWorks Database: List all the products that are red or blue
SQL Query - AdventureWorks: Exercise-37 with Solution
37. From the following table write a query in SQL to list all the products that are Red or Blue in color. Return name, color and listprice.Sorts this result by the column listprice.
Sample table: Production.Product
Sample Solution:
SELECT Name, Color, ListPrice
FROM Production.Product
WHERE Color = 'Red'
UNION ALL
SELECT Name, Color, ListPrice
FROM Production.Product
WHERE Color = 'Blue'
ORDER BY ListPrice ASC;
Sample Output:
name |color|listprice| ---------------------------+-----+---------+ Sport-100 Helmet, Blue |Blue | 34.99| Sport-100 Helmet, Red |Red | 34.99| Classic Vest, S |Blue | 63.5| Classic Vest, L |Blue | 63.5| Classic Vest, M |Blue | 63.5| LL Touring Frame - Blue, 54|Blue | 333.42| LL Touring Frame - Blue, 50|Blue | 333.42| LL Touring Frame - Blue, 44|Blue | 333.42| LL Touring Frame - Blue, 62|Blue | 333.42| LL Touring Frame - Blue, 58|Blue | 333.42| LL Road Frame - Red, 58 |Red | 337.22| LL Road Frame - Red, 60 |Red | 337.22| LL Road Frame - Red, 62 |Red | 337.22| LL Road Frame - Red, 44 |Red | 337.22| LL Road Frame - Red, 48 |Red | 337.22| ...
SQL AdventureWorks Editor:
Practice Online
Contribute your code and comments through Disqus.
Previous: Fetch rows from the middle of a sorted table.
Next: Retrieve name and associated salesorders.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
SQL: Tips of the Day
What's the difference between VARCHAR and CHAR?
VARCHAR is variable-length.
CHAR is fixed length.
If your content is a fixed size, you'll get better performance with CHAR.
Ref: https://bit.ly/3wl3ram
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook