Description: based on the customer's country grouping, the query results show the country names and customer numbers with the number of customers greater than 5.
Query syntax:
VaR group = from C in CTX. MERs
Group C by C. Country into G
Where G. Count ()> 5
Orderby G. Count () descending
Select New
{
Country = G. Key,
Customer COUNT = G. Count ()
};
Corresponding SQL:
Select [T1]. [country], [T1]. [value3] as [number of customers]
From (
Select count (*) as [value], count (*) as [value2], count (*) as [value3], [t0]. [Country]
From [DBO]. [MERs] as [t0]
Group by [t0]. [Country]
) As [T1]
Where [T1]. [value]> @ P0
Order by [T1]. [value2] DESC
-- @ P0: Input int32 (size = 0; prec = 0; scale = 0) [5]
Description: queries the countries and cities covered by customers by country or city group.
Query syntax:
VaR anonymous group = from C in CTX. MERs
Group C by new {C. City, C. Country} into G
Orderby G. Key. Country, G. Key. City
Select New
{
Country = G. Key. Country,
City = G. Key. City
};
Description: queries the order quantity separately based on whether the condition is overweight.
Query syntax:
VaR groups by condition = from o in CTX. Orders
Group O by new {condition = O. Freight> 100} into G
Select New
{
Quantity = G. Count (),
Overweight = G. Key. condition? "Yes": "no"
};