Given the following Products table:
As you can see:
- each row represents one product.
- The table has three columns: ProductID, ProductName and ProuctPrice, which contain information about each product.
- The ProductPrice values range between 10 and 300.
Based on the price range, we can say that there are three product groups : those with a price range of 1-100, those with a price range of 101-200, and those with a price range of 201-300.
Write a SELECT statement that retrieves the lowest two prices for each group.
If you want to take this challenge one step forward:
The script below used a series of simple INSERT statements to populate Products table.
Use a TSQL loop to achieve the same goal. Then, try using recursive SELECT statement.