SELECT predicate WHERE and ORDER BY


SQL Server Query

            
SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice,  
UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID >= 5
ORDER BY SupplierID;

Create SQL query with SqlQueryBuilder

            
var (sql, parameters) = new SqlQueryBuilder()  
.Select()
.Columns("ProductID", "ProductName", "SupplierID", "CategoryID", "QuantityPerUnit")
.Columns("UnitPrice", "UnitsInStock", "UnitsOnOrder", "ReorderLevel", "Discontinued")
.From("Products")
.Where(new Where(new Column("CategoryID").GreaterThanOrEqualeTo(5)))
.OrderBy(new OrderBy().SetColumnAscending("SupplierID"))
.Build();

Query build by SqlQueryBuilder

            
SELECT ProductID,
       ProductName,
       SupplierID,
       CategoryID,
       QuantityPerUnit,
       UnitPrice,
       UnitsInStock,
       UnitsOnOrder,
       ReorderLevel,
       Discontinued
FROM Products
WHERE CategoryID >= @pMAIN_2507200206539574900
ORDER BY SupplierID ASC;


            
        

Parameters (If used)

Name Value
@pMAIN_2507200206539574900 5

Query Results:

  ProductID ProductName SupplierID CategoryID QuantityPerUnit UnitPrice UnitsInStock UnitsOnOrder ReorderLevel Discontinued StockLevelStars ProductDetailsWithTabs ProductName1 ProductName2 ProductSoundexDifference FormattedProductInfo
1 7 Uncle Bob's Organic Dried Pears 3 7 12 - 1 lb pkgs. 30.0000 15 0 10 False 0
2 9 Mishi Kobe Niku 4 6 18 - 500 g pkgs. 97.0000 29 0 0 True 0
3 10 Ikura 4 8 12 - 200 ml jars 31.0000 31 0 0 False 0
4 74 Longlife Tofu 4 7 5 kg pkg. 10.0000 4 20 5 False 0
5 13 Konbu 6 8 2 kg box 6.0000 24 0 5 False 0
6 14 Tofu 6 7 40 - 100 g pkgs. 23.2500 35 0 0 False 0
7 17 Alice Mutton 7 6 20 - 1 kg tins 39.0000 0 0 0 True 0
8 18 Carnarvon Tigers 7 8 16 kg pkg. 62.5000 42 0 0 False 0
9 22 Gustaf's Knäckebröd 9 5 24 - 500 g pkgs. 21.0000 104 0 25 False 0
10 23 Tunnbröd 9 5 12 - 250 g pkgs. 9.0000 61 0 25 False 0
11 28 Rössle Sauerkraut 12 7 25 - 825 g cans 45.6000 26 0 0 True 0
12 29 Thüringer Rostbratwurst 12 6 50 bags x 30 sausgs. 123.7900 0 0 0 True 0
13 64 Wimmers gute Semmelknödel 12 5 20 bags x 4 pieces 33.2500 22 80 30 False 0
14 30 Nord-Ost Matjeshering 13 8 10 - 200 g glasses 25.8900 10 0 15 False 0
15 36 Inlagd Sill 17 8 24 - 250 g jars 19.0000 112 0 20 False 0
16 37 Gravad lax 17 8 12 - 500 g pkgs. 26.0000 11 50 25 False 0
17 73 Röd Kaviar 17 8 24 - 150 g jars 15.0000 101 0 5 False 0
18 40 Boston Crab Meat 19 8 24 - 4 oz tins 18.4000 123 0 30 False 0
19 41 Jack's New England Clam Chowder 19 8 12 - 12 oz cans 9.6500 85 0 10 False 0
20 42 Singaporean Hokkien Fried Mee 20 5 32 - 1 kg pkgs. 14.0000 26 0 0 True 0
21 45 Rogede sild 21 8 1k pkg. 9.5000 5 70 15 False 0
22 46 Spegesild 21 8 4 - 450 g glasses 12.0000 95 0 0 False 0
23 51 Manjimup Dried Apples 24 7 50 - 300 g pkgs. 53.0000 20 0 10 False 0
24 52 Filo Mix 24 5 16 - 2 kg boxes 7.0000 38 0 25 False 0
25 53 Perth Pasties 24 6 48 pieces 32.8000 0 0 0 True 0
26 54 Tourtière 25 6 16 pies 7.4500 21 0 10 False 0
27 55 Pâté chinois 25 6 24 boxes x 2 pies 24.0000 115 0 20 False 0
28 56 Gnocchi di nonna Alice 26 5 24 - 250 g pkgs. 38.0000 21 10 30 False 0
29 57 Ravioli Angelo 26 5 24 - 250 g pkgs. 19.5000 36 0 20 False 0
30 58 Escargots de Bourgogne 27 8 24 pieces 13.2500 62 0 20 False 0