AdventureWorks Database: Fetch all products with a weight of less than 10 pounds
SQL Query - AdventureWorks: Exercise-176 with Solution
176. From the following table write a query in SQL to fetch all products with a weight of less than 10 pounds or unknown color. Return the name, weight, and color for the product. Sort the result set in ascending order on name.
Sample table: Production.Product
Sample Solution:
SELECT Name, Weight, Color
FROM Production.Product
WHERE Weight < 10.00 OR Color IS NULL
ORDER BY Name;
Sample Output:
name |weight|color | --------------------------------+------+------+ Adjustable Race | | | All-Purpose Bike Stand | | | BB Ball Bearing | | | Bearing Ball | | | Bike Wash - Dissolver | | | Blade | | | Cable Lock | | | Chain Stays | | | Cone-Shaped Race | | | Crown Race | | | Cup-Shaped Race | | | Decal 1 | | | Decal 2 | | | ...
SQL AdventureWorks Editor:
Practice Online
Contribute your code and comments through Disqus.
Previous: Look for rows where middlename is NULL.
Next: List the salesperson whose salesytd begins with 1.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
SQL: Tips of the Day
ROW_NUMBER() in MySQL
SELECT t0.col3 FROM table AS t0 LEFT JOIN table AS t1 ON t0.col1=t1.col1 AND t0.col2=t1.col2 AND t1.col3>t0.col3 WHERE t1.col1 IS NULL;
Ref : https://bit.ly/3VX3Jzv
- Weekly Trends
- 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
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises