w3resource

AdventureWorks Database: Products whose names start with Lock Washer

SQL Query - AdventureWorks: Exercise-28 with Solution

28. From the following table write a query in SQL to retrieve products whose names start with 'Lock Washer'. Return product ID, and name and order the result set in ascending order on product ID column.

Sample table: Production.Product


Click to view Full table

Sample Solution:

SELECT ProductID, Name 
FROM Production.Product  
WHERE Name LIKE 'Lock Washer%'  
ORDER BY ProductID; 

Sample Output:

productid|name          |
---------+--------------+
      463|Lock Washer 4 |
      464|Lock Washer 5 |
      465|Lock Washer 10|
      466|Lock Washer 6 |
      467|Lock Washer 13|
      468|Lock Washer 8 |
      469|Lock Washer 1 |
      470|Lock Washer 7 |
      471|Lock Washer 12|
      472|Lock Washer 2 |
      473|Lock Washer 9 |
      474|Lock Washer 3 |
      475|Lock Washer 11|

SQL AdventureWorks Editor:

Practice Online


Contribute your code and comments through Disqus.

Previous: Find total cost of each order exceeds 100000.
Next: Fetch result set on an unspecified column.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Share this Tutorial / Exercise on : Facebook and Twitter

SQL: Tips of the Day

T-SQL Cast versus Convert?

CONVERT is SQL Server specific, CAST is ANSI.

CONVERT is more flexible in that you can format dates etc. Other than that, they are pretty much the same. If you don't care about the extended features, use CAST.

Ref : https://bit.ly/3VKT5M8