COUNT_BIG SQL function
1. Usage of COUNT_BIG to show customer demographics
SQL Server Query 1
-- Analyze order counts by customer and customer demographics
SELECT
c.CustomerID,
c.CompanyName,
c.ContactName,
c.Country,
COUNT_BIG(o.OrderID) AS TotalOrders, -- Use COUNT_BIG here
AVG(CAST(od.Quantity * od.UnitPrice * (1 - od.Discount) AS DECIMAL(18, 2))) AS AverageOrderValue,
MAX(CAST(od.Quantity * od.UnitPrice * (1 - od.Discount) AS DECIMAL(18, 2))) AS MaxOrderValue,
MIN(CAST(od.Quantity * od.UnitPrice * (1 - od.Discount) AS DECIMAL(18, 2))) AS MinOrderValue
FROM Customers AS c
JOIN Orders AS o ON c.CustomerID = o.CustomerID
JOIN [Order Details] AS od ON o.OrderID = od.OrderID
GROUP BY c.CustomerID, c.CompanyName, c.ContactName, c.Country
ORDER BY TotalOrders DESC;
Create SQL query with SqlQueryBuilder 1
var (sql1, parameters1) = new SqlQueryBuilder()
.Select()
.Columns("c.CustomerID","c.CompanyName","c.ContactName","c.Country")
.Column(new COUNT_BIG(new Column("o.OrderID")), "TotalOrders")
.Column(new AVG(new CAST(new ColumnArithmatic("od.Quantity").MULTIPLY("od.UnitPrice").MULTIPLY()
.StartBracket(1).SUBTRACT("od.Discount").EndBracket(), SqlDataType.DECIMAL, new Tuple<int,int>(18,2)))
, "AverageOrderValue")
.Column(new MAX(new CAST(new ColumnArithmatic("od.Quantity").MULTIPLY("od.UnitPrice").MULTIPLY()
.StartBracket(1).SUBTRACT("od.Discount").EndBracket(), SqlDataType.DECIMAL, new Tuple<int, int>(18, 2)))
, "MaxOrderValue")
.Column(new MIN(new CAST(new ColumnArithmatic("od.Quantity").MULTIPLY("od.UnitPrice").MULTIPLY()
.StartBracket(1).SUBTRACT("od.Discount").EndBracket(), SqlDataType.DECIMAL, new Tuple<int, int>(18, 2)))
, "MinOrderValue")
.From("Customers", "c")
.Join(new List<IJoin>()
{
new INNERJOIN().TableName("Orders", "o")
.On(new Column("c.CustomerID").Equale(new Column("o.CustomerID"))),
new INNERJOIN().TableName("[Order Details]", "od")
.On(new Column("o.OrderID").Equale(new Column("od.OrderID")))
})
.GroupBy(new GroupBy("c.CustomerID","c.CompanyName","c.ContactName","c.Country"))
.OrderBy(new OrderBy()
.SetColumnDescending("TotalOrders"))
.Build();
Query build by SqlQueryBuilder 1
SELECT c.CustomerID,
c.CompanyName,
c.ContactName,
c.Country,
COUNT(o.OrderID) AS TotalOrders,
AVG(CAST (od.Quantity * od.UnitPrice * (@pMAIN_2512060918543801860 - od.Discount) AS DECIMAL (18, 2))) AS AverageOrderValue,
MAX(CAST (od.Quantity * od.UnitPrice * (@pMAIN_2512060918543801861 - od.Discount) AS DECIMAL (18, 2))) AS MaxOrderValue,
MIN(CAST (od.Quantity * od.UnitPrice * (@pMAIN_2512060918543801862 - od.Discount) AS DECIMAL (18, 2))) AS MinOrderValue
FROM Customers AS c
INNER JOIN
Orders AS o
ON c.CustomerID = o.CustomerID
INNER JOIN
[Order Details] AS od
ON o.OrderID = od.OrderID
GROUP BY c.CustomerID, c.CompanyName, c.ContactName, c.Country
ORDER BY TotalOrders DESC;
Parameters (If used)
| Name |
Value |
| @pMAIN_2512060918543801860 |
1 |
| @pMAIN_2512060918543801861 |
1 |
| @pMAIN_2512060918543801862 |
1 |
Query Results 1:
| |
CustomerID |
CompanyName |
ContactName |
Country |
TotalOrders |
AverageOrderValue |
MaxOrderValue |
MinOrderValue |
| 1 |
SAVEA
|
Save-a-lot Markets
|
Jose Pavarotti
|
USA
|
116
|
899
|
5570
|
35
|
| 2 |
ERNSH
|
Ernst Handel
|
Roland Mendel
|
Austria
|
102
|
1028
|
6050
|
36
|
| 3 |
QUICK
|
QUICK-Stop
|
Horst Kloss
|
Germany
|
86
|
1282
|
15019
|
34
|
| 4 |
RATTC
|
Rattlesnake Canyon Grocery
|
Paula Wilson
|
USA
|
71
|
719
|
10540
|
14
|
| 5 |
HUNGO
|
Hungry Owl All-Night Grocers
|
Patricia McKenna
|
Ireland
|
55
|
908
|
9903
|
22
|
| 6 |
BERGS
|
Berglunds snabbköp
|
Christina Berglund
|
Sweden
|
52
|
479
|
3557
|
20
|
| 7 |
FRANK
|
Frankenversand
|
Peter Franken
|
Germany
|
48
|
555
|
2618
|
13
|
| 8 |
HILAA
|
HILARION-Abastos
|
Carlos Hernández
|
Venezuela
|
45
|
505
|
2640
|
33
|
| 9 |
FOLKO
|
Folk och fä HB
|
Maria Larsson
|
Sweden
|
45
|
657
|
4642
|
18
|
| 10 |
BONAP
|
Bon app'
|
Laurence Lebihan
|
France
|
44
|
499
|
1500
|
35
|
| 11 |
QUEEN
|
Queen Cozinha
|
Lúcia Carvalho
|
Brazil
|
40
|
642
|
6324
|
26
|
| 12 |
WHITC
|
White Clover Markets
|
Karl Jablonski
|
USA
|
40
|
684
|
6587
|
26
|
| 13 |
KOENE
|
Königlich Essen
|
Philip Cramer
|
Germany
|
39
|
792
|
7905
|
40
|
| 14 |
SUPRD
|
Suprêmes délices
|
Pascale Cartrain
|
Belgium
|
39
|
617
|
2750
|
14
|
| 15 |
LEHMS
|
Lehmanns Marktstand
|
Renate Messner
|
Germany
|
39
|
493
|
2228
|
38
|
| 16 |
WARTH
|
Wartian Herkku
|
Pirkko Koskitalo
|
Finland
|
37
|
422
|
1310
|
17
|
| 17 |
LINOD
|
LINO-Delicateses
|
Felipe Izquierdo
|
Venezuela
|
35
|
470
|
2088
|
48
|
| 18 |
BOTTM
|
Bottom-Dollar Markets
|
Elizabeth Lincoln
|
Canada
|
35
|
594
|
2958
|
37
|
| 19 |
LILAS
|
LILA-Supermercado
|
Carlos González
|
Venezuela
|
34
|
472
|
1980
|
57
|
| 20 |
HANAR
|
Hanari Carnes
|
Mario Pontes
|
Brazil
|
32
|
1026
|
15810
|
71
|
| 21 |
MEREP
|
Mère Paillarde
|
Jean Fresnière
|
Canada
|
32
|
902
|
8263
|
89
|
| 22 |
VAFFE
|
Vaffeljernet
|
Palle Ibsen
|
Denmark
|
31
|
511
|
2462
|
48
|
| 23 |
LAMAI
|
La maison d'Asie
|
Annette Roulet
|
France
|
31
|
300
|
2352
|
14
|
| 24 |
AROUT
|
Around the Horn
|
Thomas Hardy
|
UK
|
30
|
446
|
3847
|
45
|
| 25 |
RICSU
|
Richter Supermarkt
|
Michael Holz
|
Switzerland
|
30
|
644
|
4456
|
30
|
| 26 |
OTTIK
|
Ottilies Käseladen
|
Henriette Pfalzheim
|
Germany
|
29
|
430
|
1050
|
60
|
| 27 |
TORTU
|
Tortuga Restaurante
|
Miguel Angel Paolino
|
Mexico
|
29
|
372
|
3952
|
22
|
| 28 |
RICAR
|
Ricardo Adocicados
|
Janete Limeira
|
Brazil
|
27
|
461
|
2194
|
34
|
| 29 |
GODOS
|
Godos Cocina Típica
|
José Pedro Freyre
|
Spain
|
26
|
440
|
2475
|
54
|
| 30 |
WANDK
|
Die Wandernde Kuh
|
Rita Müller
|
Germany
|
26
|
368
|
1280
|
47
|
| 31 |
BLONP
|
Blondesddsl père et fils
|
Frédérique Citeaux
|
France
|
26
|
712
|
3465
|
48
|
| 32 |
SEVES
|
Seven Seas Imports
|
Hari Kumar
|
UK
|
26
|
623
|
2067
|
46
|
| 33 |
VICTE
|
Victuailles en stock
|
Mary Saveley
|
France
|
25
|
367
|
1972
|
8
|
| 34 |
OLDWO
|
Old World Delicatessen
|
Rene Phillips
|
USA
|
24
|
632
|
2227
|
135
|
| 35 |
QUEDE
|
Que Delícia
|
Bernardo Batista
|
Brazil
|
24
|
277
|
1000
|
24
|
| 36 |
ISLAT
|
Island Trading
|
Helen Bennett
|
UK
|
23
|
267
|
855
|
24
|
| 37 |
PICCO
|
Piccolo und mehr
|
Georg Pipps
|
Austria
|
23
|
1005
|
8432
|
100
|
| 38 |
BSBEV
|
B's Beverages
|
Victoria Ashworth
|
UK
|
22
|
276
|
1380
|
34
|
| 39 |
GREAL
|
Great Lakes Food Market
|
Howard Snyder
|
USA
|
22
|
841
|
7509
|
16
|
| 40 |
CHOPS
|
Chop-suey Chinese
|
Yang Wang
|
Switzerland
|
22
|
561
|
1520
|
36
|
| 41 |
REGGC
|
Reggiani Caseifici
|
Maurizio Moroni
|
Italy
|
22
|
320
|
1252
|
23
|
| 42 |
MAGAA
|
Magazzini Alimentari Riuniti
|
Giovanni Rovelli
|
Italy
|
21
|
341
|
887
|
30
|
| 43 |
EASTC
|
Eastern Connection
|
Ann Devon
|
UK
|
21
|
702
|
2079
|
75
|
| 44 |
SPLIR
|
Split Rail Beer & Ale
|
Art Braunschweiger
|
USA
|
20
|
572
|
4005
|
48
|
| 45 |
FURIB
|
Furia Bacalhau e Frutos do Mar
|
Lino Rodriguez
|
Portugal
|
20
|
321
|
778
|
36
|
| 46 |
GOURL
|
Gourmet Lanchonetes
|
André Fonseca
|
Brazil
|
19
|
442
|
1600
|
38
|
| 47 |
FAMIA
|
Familia Arquibaldo
|
Aria Cruz
|
Brazil
|
19
|
216
|
779
|
28
|
| 48 |
WELLI
|
Wellington Importadora
|
Paula Parente
|
Brazil
|
19
|
319
|
1396
|
8
|
| 49 |
MAISD
|
Maison Dewey
|
Catherine Dewey
|
Belgium
|
17
|
572
|
2090
|
99
|
| 50 |
WILMK
|
Wilman Kala
|
Matti Karttunen
|
Finland
|
17
|
185
|
550
|
36
|
| 51 |
ANTON
|
Antonio Moreno Taquería
|
Antonio Moreno
|
Mexico
|
17
|
413
|
945
|
17
|
| 52 |
FOLIG
|
Folies gourmandes
|
Martine Rancé
|
France
|
16
|
729
|
3125
|
15
|
| 53 |
WOLZA
|
Wolski Zajazd
|
Zbyszek Piestrzeniewicz
|
Poland
|
16
|
220
|
591
|
22
|
| 54 |
SANTG
|
Santé Gourmet
|
Jonas Bergulfsen
|
Norway
|
16
|
358
|
2108
|
18
|
| 55 |
SIMOB
|
Simons bistro
|
Jytte Petersen
|
Denmark
|
15
|
1121
|
10540
|
14
|
| 56 |
ROMEY
|
Romero y tomillo
|
Alejandra Camino
|
Spain
|
14
|
104
|
340
|
7
|
| 57 |
TOMSP
|
Toms Spezialitäten
|
Karin Josephs
|
Germany
|
14
|
341
|
1696
|
27
|
| 58 |
LONEP
|
Lonesome Pine Restaurant
|
Fran Wilson
|
USA
|
14
|
304
|
1060
|
30
|
| 59 |
BLAUS
|
Blauer See Delikatessen
|
Hanna Moos
|
Germany
|
14
|
231
|
714
|
30
|
| 60 |
PERIC
|
Pericles Comidas clásicas
|
Guillermo Fernández
|
Mexico
|
14
|
303
|
1060
|
62
|
| 61 |
TRADH
|
Tradição Hipermercados
|
Anabela Domingues
|
Brazil
|
13
|
526
|
1296
|
150
|
| 62 |
RANCH
|
Rancho grande
|
Sergio Gutiérrez
|
Argentina
|
12
|
237
|
527
|
36
|
| 63 |
ALFKI
|
Alfreds Futterkiste
|
Maria Anders
|
Germany
|
12
|
356
|
878
|
18
|
| 64 |
LACOR
|
La corne d'abondance
|
Daniel Tonini
|
France
|
11
|
181
|
439
|
17
|
| 65 |
MORGK
|
Morgenstern Gesundkost
|
Alexander Feuer
|
Germany
|
11
|
458
|
1044
|
114
|
| 66 |
OCEAN
|
Océano Atlántico Ltda.
|
Yvonne Moncada
|
Argentina
|
11
|
314
|
1215
|
30
|
| 67 |
CACTU
|
Cactus Comidas para llevar
|
Patricio Simpson
|
Argentina
|
11
|
164
|
364
|
12
|
| 68 |
PRINI
|
Princesa Isabel Vinhos
|
Isabel de Castro
|
Portugal
|
10
|
504
|
1237
|
68
|
| 69 |
COMMI
|
Comércio Mineiro
|
Pedro Afonso
|
Brazil
|
10
|
381
|
1485
|
48
|
| 70 |
VINET
|
Vins et alcools Chevalier
|
Paul Henriot
|
France
|
10
|
148
|
344
|
24
|
| 71 |
LETSS
|
Let's Stop N Shop
|
Jaime Yorres
|
USA
|
10
|
307
|
758
|
23
|
| 72 |
ANATR
|
Ana Trujillo Emparedados y helados
|
Ana Trujillo
|
Mexico
|
10
|
140
|
348
|
28
|
| 73 |
DRACD
|
Drachenblut Delikatessen
|
Sven Ottlieb
|
Germany
|
10
|
376
|
1650
|
42
|
| 74 |
FRANS
|
Franchi S.p.A.
|
Paolo Accorti
|
Italy
|
10
|
154
|
530
|
18
|
| 75 |
HUNGC
|
Hungry Coyote Import Store
|
Yoshi Latimer
|
USA
|
9
|
340
|
1701
|
29
|
| 76 |
TRAIH
|
Trail's Head Gourmet Provisioners
|
Helvetius Nagy
|
USA
|
9
|
174
|
493
|
35
|
| 77 |
DUMON
|
Du monde entier
|
Janine Labrune
|
France
|
9
|
179
|
585
|
54
|
| 78 |
THECR
|
The Cracker Box
|
Liu Wong
|
USA
|
8
|
243
|
742
|
42
|
| 79 |
LAUGB
|
Laughing Bacchus Wine Cellars
|
Yoshi Tannamuri
|
Canada
|
8
|
65
|
154
|
22
|
| 80 |
GALED
|
Galería del gastrónomo
|
Eduardo Saavedra
|
Spain
|
8
|
104
|
186
|
47
|
| 81 |
THEBI
|
The Big Cheese
|
Liz Nixon
|
USA
|
7
|
480
|
2635
|
69
|
| 82 |
CONSH
|
Consolidated Holdings
|
Elizabeth Brown
|
UK
|
7
|
245
|
640
|
4
|
| 83 |
NORTS
|
North/South
|
Simon Crowther
|
UK
|
6
|
108
|
220
|
42
|
| 84 |
FRANR
|
France restauration
|
Carine Schmitt
|
France
|
6
|
528
|
1733
|
159
|
| 85 |
BOLID
|
Bólido Comidas preparadas
|
Martín Sommer
|
Spain
|
6
|
705
|
1856
|
224
|
| 86 |
SPECD
|
Spécialités du monde
|
Dominique Perrier
|
France
|
6
|
403
|
1317
|
52
|
| 87 |
GROSR
|
GROSELLA-Restaurante
|
Manuel Pereira
|
Venezuela
|
4
|
372
|
990
|
77
|
| 88 |
CENTC
|
Centro comercial Moctezuma
|
Francisco Chang
|
Mexico
|
2
|
50
|
80
|
20
|
| 89 |
LAZYK
|
Lazy K Kountry Store
|
John Steel
|
USA
|
2
|
178
|
210
|
147
|
2. Usage of COUNT_BIG to find most valuable customers based on orders
SQL Server Query 2
-- Identify customers with a very large number of orders (e.g., more than 100)
-- This helps in identifying your most valuable customers.
SELECT
c.CustomerID,
c.CompanyName,
COUNT_BIG(o.OrderID) AS TotalOrders
FROM Customers AS c
JOIN Orders AS o ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerID, c.CompanyName
HAVING COUNT_BIG(o.OrderID) > 10 -- Use COUNT_BIG in the HAVING clause
ORDER BY TotalOrders DESC;
Create SQL query with SqlQueryBuilder 2
var (sql2, parameters2) = new SqlQueryBuilder()
.Select()
.Columns("c.CustomerID", "c.CompanyName")
.Column(new COUNT_BIG(new Column("o.OrderID")), "TotalOrders")
.From("Customers", "c")
.Join(new List<IJoin>()
{
new INNERJOIN().TableName("Orders","o")
.On(new Column("c.CustomerID").Equale(new Column("o.CustomerID")))
})
.GroupBy(new GroupBy("c.CustomerID", "CompanyName"))
.Having(new Having(new COUNT_BIG(new Column("o.OrderID")).GreaterThan(10)))
.OrderBy(new OrderBy().SetColumnDescending("TotalOrders"))
.Build();
Query build by SqlQueryBuilder 2
SELECT c.CustomerID,
c.CompanyName,
COUNT(o.OrderID) AS TotalOrders
FROM Customers AS c
INNER JOIN
Orders AS o
ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerID, CompanyName
HAVING COUNT(o.OrderID) > @pMAIN_2512060918544025510
ORDER BY TotalOrders DESC;
Parameters (If used)
| Name |
Value |
| @pMAIN_2512060918544025510 |
10 |
Query Results 2:
| |
CustomerID |
CompanyName |
TotalOrders |
| 1 |
SAVEA
|
Save-a-lot Markets
|
31
|
| 2 |
ERNSH
|
Ernst Handel
|
30
|
| 3 |
QUICK
|
QUICK-Stop
|
28
|
| 4 |
FOLKO
|
Folk och fä HB
|
19
|
| 5 |
HUNGO
|
Hungry Owl All-Night Grocers
|
19
|
| 6 |
BERGS
|
Berglunds snabbköp
|
18
|
| 7 |
RATTC
|
Rattlesnake Canyon Grocery
|
18
|
| 8 |
HILAA
|
HILARION-Abastos
|
18
|
| 9 |
BONAP
|
Bon app'
|
17
|
| 10 |
FRANK
|
Frankenversand
|
15
|
| 11 |
LEHMS
|
Lehmanns Marktstand
|
15
|
| 12 |
WARTH
|
Wartian Herkku
|
15
|
| 13 |
WHITC
|
White Clover Markets
|
14
|
| 14 |
LILAS
|
LILA-Supermercado
|
14
|
| 15 |
KOENE
|
Königlich Essen
|
14
|
| 16 |
LAMAI
|
La maison d'Asie
|
14
|
| 17 |
HANAR
|
Hanari Carnes
|
14
|
| 18 |
BOTTM
|
Bottom-Dollar Markets
|
14
|
| 19 |
AROUT
|
Around the Horn
|
13
|
| 20 |
MEREP
|
Mère Paillarde
|
13
|
| 21 |
QUEEN
|
Queen Cozinha
|
13
|
| 22 |
LINOD
|
LINO-Delicateses
|
12
|
| 23 |
SUPRD
|
Suprêmes délices
|
12
|
| 24 |
REGGC
|
Reggiani Caseifici
|
12
|
| 25 |
RICAR
|
Ricardo Adocicados
|
11
|
| 26 |
VAFFE
|
Vaffeljernet
|
11
|
| 27 |
BLONP
|
Blondesddsl père et fils
|
11
|
| 28 |
GREAL
|
Great Lakes Food Market
|
11
|
3. Usage of CHECKSUM to find distribution of orders by ship country
SQL Server Query 3
-- Analyze the distribution of orders by ship country, using COUNT_BIG
SELECT
o.ShipCountry,
COUNT_BIG(o.OrderID) AS OrderCount,
CAST(COUNT_BIG(o.OrderID) * 100.0 / (SELECT COUNT_BIG(*) FROM Orders) AS DECIMAL(5, 2)) AS PercentageOfTotalOrders
FROM Orders AS o
GROUP BY o.ShipCountry
ORDER BY OrderCount DESC;
Create SQL query with SqlQueryBuilder 3
var (sql3, parameters3) = new SqlQueryBuilder()
.Select()
.Column("o.ShipCountry", "ShipCountry")
.Column(new COUNT_BIG(new Column("o.OrderID")), "OrderCount")
.Column(new CAST(new ColumnArithmatic(new COUNT_BIG(new Column("o.OrderID"))).MULTIPLY(100.0)
.DIVIDE(new SqlQueryBuilder()
.Select()
.Column(new COUNT_BIG(new Column("*")),"OrderCount")
.From("Orders")), SqlDataType.DECIMAL, new Tuple<int,int>(5, 2)), "PercentageOfTotalOrders")
.From("Orders", "o")
.GroupBy(new GroupBy("o.ShipCountry"))
.OrderBy(new OrderBy().SetColumnDescending("OrderCount"))
.Build();
Query build by SqlQueryBuilder 3
SELECT o.ShipCountry AS ShipCountry,
COUNT(o.OrderID) AS OrderCount,
CAST (COUNT(o.OrderID) * @pMAIN_2512060918544208310 / (SELECT COUNT(*) AS OrderCount
FROM Orders) AS DECIMAL (5, 2)) AS PercentageOfTotalOrders
FROM Orders AS o
GROUP BY o.ShipCountry
ORDER BY OrderCount DESC;
Parameters (If used)
| Name |
Value |
| @pMAIN_2512060918544208310 |
100 |
Query Results 3:
| |
ShipCountry |
OrderCount |
PercentageOfTotalOrders |
| 1 |
USA
|
122
|
14.70
|
| 2 |
Germany
|
122
|
14.70
|
| 3 |
Brazil
|
83
|
10.00
|
| 4 |
France
|
77
|
9.28
|
| 5 |
UK
|
56
|
6.75
|
| 6 |
Venezuela
|
46
|
5.54
|
| 7 |
Austria
|
40
|
4.82
|
| 8 |
Sweden
|
37
|
4.46
|
| 9 |
Canada
|
30
|
3.61
|
| 10 |
Mexico
|
28
|
3.37
|
| 11 |
Italy
|
28
|
3.37
|
| 12 |
Spain
|
23
|
2.77
|
| 13 |
Finland
|
22
|
2.65
|
| 14 |
Ireland
|
19
|
2.29
|
| 15 |
Belgium
|
19
|
2.29
|
| 16 |
Switzerland
|
18
|
2.17
|
| 17 |
Denmark
|
18
|
2.17
|
| 18 |
Argentina
|
16
|
1.93
|
| 19 |
Portugal
|
13
|
1.57
|
| 20 |
Poland
|
7
|
0.84
|
| 21 |
Norway
|
6
|
0.72
|
4. Usage of COUNT_BIG as windows function to show change in customer data
SQL Server Query 4
-- Find orders per customer
SELECT
o.OrderID,
o.CustomerID,
COUNT_BIG(*) OVER (PARTITION BY o.CustomerID) AS OrdersPerCustomer
FROM
Orders o;
Create SQL query with SqlQueryBuilder 4
var (sql4, parameters4) = new SqlQueryBuilder()
.Select()
.Column("o.OrderID", "o.CustomerID")
.Column(new COUNT_BIG(new Column("*")).OVER(new OVER().PARTITION_BY(new Column("o.CustomerID"))), "OrdersPerCustomer")
.From("Orders", "o")
.Build();
Query build by SqlQueryBuilder 4
SELECT o.OrderID,
o.CustomerID,
COUNT(*) OVER (PARTITION BY o.CustomerID) AS OrdersPerCustomer
FROM Orders AS o;
Parameters (If used)
Query Results 4:
| |
OrderID |
CustomerID |
OrdersPerCustomer |
| 1 |
10643
|
ALFKI
|
6
|
| 2 |
10692
|
ALFKI
|
6
|
| 3 |
10702
|
ALFKI
|
6
|
| 4 |
10835
|
ALFKI
|
6
|
| 5 |
10952
|
ALFKI
|
6
|
| 6 |
11011
|
ALFKI
|
6
|
| 7 |
10308
|
ANATR
|
4
|
| 8 |
10625
|
ANATR
|
4
|
| 9 |
10759
|
ANATR
|
4
|
| 10 |
10926
|
ANATR
|
4
|
| 11 |
10365
|
ANTON
|
7
|
| 12 |
10507
|
ANTON
|
7
|
| 13 |
10535
|
ANTON
|
7
|
| 14 |
10573
|
ANTON
|
7
|
| 15 |
10677
|
ANTON
|
7
|
| 16 |
10682
|
ANTON
|
7
|
| 17 |
10856
|
ANTON
|
7
|
| 18 |
10355
|
AROUT
|
13
|
| 19 |
10383
|
AROUT
|
13
|
| 20 |
10453
|
AROUT
|
13
|
| 21 |
10558
|
AROUT
|
13
|
| 22 |
10707
|
AROUT
|
13
|
| 23 |
10741
|
AROUT
|
13
|
| 24 |
10743
|
AROUT
|
13
|
| 25 |
10768
|
AROUT
|
13
|
| 26 |
10793
|
AROUT
|
13
|
| 27 |
10864
|
AROUT
|
13
|
| 28 |
10920
|
AROUT
|
13
|
| 29 |
10953
|
AROUT
|
13
|
| 30 |
11016
|
AROUT
|
13
|
| 31 |
10278
|
BERGS
|
18
|
| 32 |
10280
|
BERGS
|
18
|
| 33 |
10384
|
BERGS
|
18
|
| 34 |
10444
|
BERGS
|
18
|
| 35 |
10445
|
BERGS
|
18
|
| 36 |
10524
|
BERGS
|
18
|
| 37 |
10572
|
BERGS
|
18
|
| 38 |
10626
|
BERGS
|
18
|
| 39 |
10654
|
BERGS
|
18
|
| 40 |
10672
|
BERGS
|
18
|
| 41 |
10689
|
BERGS
|
18
|
| 42 |
10733
|
BERGS
|
18
|
| 43 |
10778
|
BERGS
|
18
|
| 44 |
10837
|
BERGS
|
18
|
| 45 |
10857
|
BERGS
|
18
|
| 46 |
10866
|
BERGS
|
18
|
| 47 |
10875
|
BERGS
|
18
|
| 48 |
10924
|
BERGS
|
18
|
| 49 |
10501
|
BLAUS
|
7
|
| 50 |
10509
|
BLAUS
|
7
|
| 51 |
10582
|
BLAUS
|
7
|
| 52 |
10614
|
BLAUS
|
7
|
| 53 |
10853
|
BLAUS
|
7
|
| 54 |
10956
|
BLAUS
|
7
|
| 55 |
11058
|
BLAUS
|
7
|
| 56 |
10265
|
BLONP
|
11
|
| 57 |
10297
|
BLONP
|
11
|
| 58 |
10360
|
BLONP
|
11
|
| 59 |
10436
|
BLONP
|
11
|
| 60 |
10449
|
BLONP
|
11
|
| 61 |
10559
|
BLONP
|
11
|
| 62 |
10566
|
BLONP
|
11
|
| 63 |
10584
|
BLONP
|
11
|
| 64 |
10628
|
BLONP
|
11
|
| 65 |
10679
|
BLONP
|
11
|
| 66 |
10826
|
BLONP
|
11
|
| 67 |
10326
|
BOLID
|
3
|
| 68 |
10801
|
BOLID
|
3
|
| 69 |
10970
|
BOLID
|
3
|
| 70 |
10331
|
BONAP
|
17
|
| 71 |
10340
|
BONAP
|
17
|
| 72 |
10362
|
BONAP
|
17
|
| 73 |
10470
|
BONAP
|
17
|
| 74 |
10511
|
BONAP
|
17
|
| 75 |
10525
|
BONAP
|
17
|
| 76 |
10663
|
BONAP
|
17
|
| 77 |
10715
|
BONAP
|
17
|
| 78 |
10730
|
BONAP
|
17
|
| 79 |
10732
|
BONAP
|
17
|
| 80 |
10755
|
BONAP
|
17
|
| 81 |
10827
|
BONAP
|
17
|
| 82 |
10871
|
BONAP
|
17
|
| 83 |
10876
|
BONAP
|
17
|
| 84 |
10932
|
BONAP
|
17
|
| 85 |
10940
|
BONAP
|
17
|
| 86 |
11076
|
BONAP
|
17
|
| 87 |
10389
|
BOTTM
|
14
|
| 88 |
10410
|
BOTTM
|
14
|
| 89 |
10411
|
BOTTM
|
14
|
| 90 |
10431
|
BOTTM
|
14
|
| 91 |
10492
|
BOTTM
|
14
|
| 92 |
10742
|
BOTTM
|
14
|
| 93 |
10918
|
BOTTM
|
14
|
| 94 |
10944
|
BOTTM
|
14
|
| 95 |
10949
|
BOTTM
|
14
|
| 96 |
10975
|
BOTTM
|
14
|
| 97 |
10982
|
BOTTM
|
14
|
| 98 |
11027
|
BOTTM
|
14
|
| 99 |
11045
|
BOTTM
|
14
|
| 100 |
11048
|
BOTTM
|
14
|
| 101 |
10289
|
BSBEV
|
10
|
| 102 |
10471
|
BSBEV
|
10
|
| 103 |
10484
|
BSBEV
|
10
|
| 104 |
10538
|
BSBEV
|
10
|
| 105 |
10539
|
BSBEV
|
10
|
| 106 |
10578
|
BSBEV
|
10
|
| 107 |
10599
|
BSBEV
|
10
|
| 108 |
10943
|
BSBEV
|
10
|
| 109 |
10947
|
BSBEV
|
10
|
| 110 |
11023
|
BSBEV
|
10
|
| 111 |
10521
|
CACTU
|
6
|
| 112 |
10782
|
CACTU
|
6
|
| 113 |
10819
|
CACTU
|
6
|
| 114 |
10881
|
CACTU
|
6
|
| 115 |
10937
|
CACTU
|
6
|
| 116 |
11054
|
CACTU
|
6
|
| 117 |
10259
|
CENTC
|
1
|
| 118 |
10254
|
CHOPS
|
8
|
| 119 |
10370
|
CHOPS
|
8
|
| 120 |
10519
|
CHOPS
|
8
|
| 121 |
10731
|
CHOPS
|
8
|
| 122 |
10746
|
CHOPS
|
8
|
| 123 |
10966
|
CHOPS
|
8
|
| 124 |
11029
|
CHOPS
|
8
|
| 125 |
11041
|
CHOPS
|
8
|
| 126 |
10290
|
COMMI
|
5
|
| 127 |
10466
|
COMMI
|
5
|
| 128 |
10494
|
COMMI
|
5
|
| 129 |
10969
|
COMMI
|
5
|
| 130 |
11042
|
COMMI
|
5
|
| 131 |
10435
|
CONSH
|
3
|
| 132 |
10462
|
CONSH
|
3
|
| 133 |
10848
|
CONSH
|
3
|
| 134 |
10363
|
DRACD
|
6
|
| 135 |
10391
|
DRACD
|
6
|
| 136 |
10797
|
DRACD
|
6
|
| 137 |
10825
|
DRACD
|
6
|
| 138 |
11036
|
DRACD
|
6
|
| 139 |
11067
|
DRACD
|
6
|
| 140 |
10311
|
DUMON
|
4
|
| 141 |
10609
|
DUMON
|
4
|
| 142 |
10683
|
DUMON
|
4
|
| 143 |
10890
|
DUMON
|
4
|
| 144 |
10364
|
EASTC
|
8
|
| 145 |
10400
|
EASTC
|
8
|
| 146 |
10532
|
EASTC
|
8
|
| 147 |
10726
|
EASTC
|
8
|
| 148 |
10987
|
EASTC
|
8
|
| 149 |
11024
|
EASTC
|
8
|
| 150 |
11047
|
EASTC
|
8
|
| 151 |
11056
|
EASTC
|
8
|
| 152 |
10258
|
ERNSH
|
30
|
| 153 |
10263
|
ERNSH
|
30
|
| 154 |
10351
|
ERNSH
|
30
|
| 155 |
10368
|
ERNSH
|
30
|
| 156 |
10382
|
ERNSH
|
30
|
| 157 |
10390
|
ERNSH
|
30
|
| 158 |
10402
|
ERNSH
|
30
|
| 159 |
10403
|
ERNSH
|
30
|
| 160 |
10430
|
ERNSH
|
30
|
| 161 |
10442
|
ERNSH
|
30
|
| 162 |
10514
|
ERNSH
|
30
|
| 163 |
10571
|
ERNSH
|
30
|
| 164 |
10595
|
ERNSH
|
30
|
| 165 |
10633
|
ERNSH
|
30
|
| 166 |
10667
|
ERNSH
|
30
|
| 167 |
10698
|
ERNSH
|
30
|
| 168 |
10764
|
ERNSH
|
30
|
| 169 |
10771
|
ERNSH
|
30
|
| 170 |
10773
|
ERNSH
|
30
|
| 171 |
10776
|
ERNSH
|
30
|
| 172 |
10795
|
ERNSH
|
30
|
| 173 |
10836
|
ERNSH
|
30
|
| 174 |
10854
|
ERNSH
|
30
|
| 175 |
10895
|
ERNSH
|
30
|
| 176 |
10968
|
ERNSH
|
30
|
| 177 |
10979
|
ERNSH
|
30
|
| 178 |
10990
|
ERNSH
|
30
|
| 179 |
11008
|
ERNSH
|
30
|
| 180 |
11017
|
ERNSH
|
30
|
| 181 |
11072
|
ERNSH
|
30
|
| 182 |
10347
|
FAMIA
|
7
|
| 183 |
10386
|
FAMIA
|
7
|
| 184 |
10414
|
FAMIA
|
7
|
| 185 |
10512
|
FAMIA
|
7
|
| 186 |
10581
|
FAMIA
|
7
|
| 187 |
10650
|
FAMIA
|
7
|
| 188 |
10725
|
FAMIA
|
7
|
| 189 |
10408
|
FOLIG
|
5
|
| 190 |
10480
|
FOLIG
|
5
|
| 191 |
10634
|
FOLIG
|
5
|
| 192 |
10763
|
FOLIG
|
5
|
| 193 |
10789
|
FOLIG
|
5
|
| 194 |
10264
|
FOLKO
|
19
|
| 195 |
10327
|
FOLKO
|
19
|
| 196 |
10378
|
FOLKO
|
19
|
| 197 |
10434
|
FOLKO
|
19
|
| 198 |
10460
|
FOLKO
|
19
|
| 199 |
10533
|
FOLKO
|
19
|
| 200 |
10561
|
FOLKO
|
19
|
| 201 |
10703
|
FOLKO
|
19
|
| 202 |
10762
|
FOLKO
|
19
|
| 203 |
10774
|
FOLKO
|
19
|
| 204 |
10824
|
FOLKO
|
19
|
| 205 |
10880
|
FOLKO
|
19
|
| 206 |
10902
|
FOLKO
|
19
|
| 207 |
10955
|
FOLKO
|
19
|
| 208 |
10977
|
FOLKO
|
19
|
| 209 |
10980
|
FOLKO
|
19
|
| 210 |
10993
|
FOLKO
|
19
|
| 211 |
11001
|
FOLKO
|
19
|
| 212 |
11050
|
FOLKO
|
19
|
| 213 |
10267
|
FRANK
|
15
|
| 214 |
10337
|
FRANK
|
15
|
| 215 |
10342
|
FRANK
|
15
|
| 216 |
10396
|
FRANK
|
15
|
| 217 |
10488
|
FRANK
|
15
|
| 218 |
10560
|
FRANK
|
15
|
| 219 |
10623
|
FRANK
|
15
|
| 220 |
10653
|
FRANK
|
15
|
| 221 |
10670
|
FRANK
|
15
|
| 222 |
10675
|
FRANK
|
15
|
| 223 |
10717
|
FRANK
|
15
|
| 224 |
10791
|
FRANK
|
15
|
| 225 |
10859
|
FRANK
|
15
|
| 226 |
10929
|
FRANK
|
15
|
| 227 |
11012
|
FRANK
|
15
|
| 228 |
10671
|
FRANR
|
3
|
| 229 |
10860
|
FRANR
|
3
|
| 230 |
10971
|
FRANR
|
3
|
| 231 |
10422
|
FRANS
|
6
|
| 232 |
10710
|
FRANS
|
6
|
| 233 |
10753
|
FRANS
|
6
|
| 234 |
10807
|
FRANS
|
6
|
| 235 |
11026
|
FRANS
|
6
|
| 236 |
11060
|
FRANS
|
6
|
| 237 |
10328
|
FURIB
|
8
|
| 238 |
10352
|
FURIB
|
8
|
| 239 |
10464
|
FURIB
|
8
|
| 240 |
10491
|
FURIB
|
8
|
| 241 |
10551
|
FURIB
|
8
|
| 242 |
10604
|
FURIB
|
8
|
| 243 |
10664
|
FURIB
|
8
|
| 244 |
10963
|
FURIB
|
8
|
| 245 |
10366
|
GALED
|
5
|
| 246 |
10426
|
GALED
|
5
|
| 247 |
10568
|
GALED
|
5
|
| 248 |
10887
|
GALED
|
5
|
| 249 |
10928
|
GALED
|
5
|
| 250 |
10303
|
GODOS
|
10
|
| 251 |
10550
|
GODOS
|
10
|
| 252 |
10629
|
GODOS
|
10
|
| 253 |
10872
|
GODOS
|
10
|
| 254 |
10874
|
GODOS
|
10
|
| 255 |
10888
|
GODOS
|
10
|
| 256 |
10911
|
GODOS
|
10
|
| 257 |
10948
|
GODOS
|
10
|
| 258 |
11009
|
GODOS
|
10
|
| 259 |
11037
|
GODOS
|
10
|
| 260 |
10423
|
GOURL
|
9
|
| 261 |
10652
|
GOURL
|
9
|
| 262 |
10685
|
GOURL
|
9
|
| 263 |
10709
|
GOURL
|
9
|
| 264 |
10734
|
GOURL
|
9
|
| 265 |
10777
|
GOURL
|
9
|
| 266 |
10790
|
GOURL
|
9
|
| 267 |
10959
|
GOURL
|
9
|
| 268 |
11049
|
GOURL
|
9
|
| 269 |
10528
|
GREAL
|
11
|
| 270 |
10589
|
GREAL
|
11
|
| 271 |
10616
|
GREAL
|
11
|
| 272 |
10617
|
GREAL
|
11
|
| 273 |
10656
|
GREAL
|
11
|
| 274 |
10681
|
GREAL
|
11
|
| 275 |
10816
|
GREAL
|
11
|
| 276 |
10936
|
GREAL
|
11
|
| 277 |
11006
|
GREAL
|
11
|
| 278 |
11040
|
GREAL
|
11
|
| 279 |
11061
|
GREAL
|
11
|
| 280 |
10268
|
GROSR
|
2
|
| 281 |
10785
|
GROSR
|
2
|
| 282 |
10250
|
HANAR
|
14
|
| 283 |
10253
|
HANAR
|
14
|
| 284 |
10541
|
HANAR
|
14
|
| 285 |
10645
|
HANAR
|
14
|
| 286 |
10690
|
HANAR
|
14
|
| 287 |
10770
|
HANAR
|
14
|
| 288 |
10783
|
HANAR
|
14
|
| 289 |
10886
|
HANAR
|
14
|
| 290 |
10903
|
HANAR
|
14
|
| 291 |
10922
|
HANAR
|
14
|
| 292 |
10925
|
HANAR
|
14
|
| 293 |
10981
|
HANAR
|
14
|
| 294 |
11022
|
HANAR
|
14
|
| 295 |
11052
|
HANAR
|
14
|
| 296 |
10257
|
HILAA
|
18
|
| 297 |
10395
|
HILAA
|
18
|
| 298 |
10476
|
HILAA
|
18
|
| 299 |
10486
|
HILAA
|
18
|
| 300 |
10490
|
HILAA
|
18
|
| 301 |
10498
|
HILAA
|
18
|
| 302 |
10552
|
HILAA
|
18
|
| 303 |
10601
|
HILAA
|
18
|
| 304 |
10613
|
HILAA
|
18
|
| 305 |
10641
|
HILAA
|
18
|
| 306 |
10705
|
HILAA
|
18
|
| 307 |
10796
|
HILAA
|
18
|
| 308 |
10863
|
HILAA
|
18
|
| 309 |
10901
|
HILAA
|
18
|
| 310 |
10957
|
HILAA
|
18
|
| 311 |
10960
|
HILAA
|
18
|
| 312 |
10976
|
HILAA
|
18
|
| 313 |
11055
|
HILAA
|
18
|
| 314 |
10375
|
HUNGC
|
5
|
| 315 |
10394
|
HUNGC
|
5
|
| 316 |
10415
|
HUNGC
|
5
|
| 317 |
10600
|
HUNGC
|
5
|
| 318 |
10660
|
HUNGC
|
5
|
| 319 |
10298
|
HUNGO
|
19
|
| 320 |
10309
|
HUNGO
|
19
|
| 321 |
10335
|
HUNGO
|
19
|
| 322 |
10373
|
HUNGO
|
19
|
| 323 |
10380
|
HUNGO
|
19
|
| 324 |
10429
|
HUNGO
|
19
|
| 325 |
10503
|
HUNGO
|
19
|
| 326 |
10516
|
HUNGO
|
19
|
| 327 |
10567
|
HUNGO
|
19
|
| 328 |
10646
|
HUNGO
|
19
|
| 329 |
10661
|
HUNGO
|
19
|
| 330 |
10687
|
HUNGO
|
19
|
| 331 |
10701
|
HUNGO
|
19
|
| 332 |
10712
|
HUNGO
|
19
|
| 333 |
10736
|
HUNGO
|
19
|
| 334 |
10897
|
HUNGO
|
19
|
| 335 |
10912
|
HUNGO
|
19
|
| 336 |
10985
|
HUNGO
|
19
|
| 337 |
11063
|
HUNGO
|
19
|
| 338 |
10315
|
ISLAT
|
10
|
| 339 |
10318
|
ISLAT
|
10
|
| 340 |
10321
|
ISLAT
|
10
|
| 341 |
10473
|
ISLAT
|
10
|
| 342 |
10621
|
ISLAT
|
10
|
| 343 |
10674
|
ISLAT
|
10
|
| 344 |
10749
|
ISLAT
|
10
|
| 345 |
10798
|
ISLAT
|
10
|
| 346 |
10829
|
ISLAT
|
10
|
| 347 |
10933
|
ISLAT
|
10
|
| 348 |
10323
|
KOENE
|
14
|
| 349 |
10325
|
KOENE
|
14
|
| 350 |
10456
|
KOENE
|
14
|
| 351 |
10457
|
KOENE
|
14
|
| 352 |
10468
|
KOENE
|
14
|
| 353 |
10506
|
KOENE
|
14
|
| 354 |
10542
|
KOENE
|
14
|
| 355 |
10630
|
KOENE
|
14
|
| 356 |
10718
|
KOENE
|
14
|
| 357 |
10799
|
KOENE
|
14
|
| 358 |
10817
|
KOENE
|
14
|
| 359 |
10849
|
KOENE
|
14
|
| 360 |
10893
|
KOENE
|
14
|
| 361 |
11028
|
KOENE
|
14
|
| 362 |
10858
|
LACOR
|
4
|
| 363 |
10927
|
LACOR
|
4
|
| 364 |
10972
|
LACOR
|
4
|
| 365 |
10973
|
LACOR
|
4
|
| 366 |
10350
|
LAMAI
|
14
|
| 367 |
10358
|
LAMAI
|
14
|
| 368 |
10371
|
LAMAI
|
14
|
| 369 |
10413
|
LAMAI
|
14
|
| 370 |
10425
|
LAMAI
|
14
|
| 371 |
10454
|
LAMAI
|
14
|
| 372 |
10493
|
LAMAI
|
14
|
| 373 |
10500
|
LAMAI
|
14
|
| 374 |
10610
|
LAMAI
|
14
|
| 375 |
10631
|
LAMAI
|
14
|
| 376 |
10787
|
LAMAI
|
14
|
| 377 |
10832
|
LAMAI
|
14
|
| 378 |
10923
|
LAMAI
|
14
|
| 379 |
11051
|
LAMAI
|
14
|
| 380 |
10495
|
LAUGB
|
3
|
| 381 |
10620
|
LAUGB
|
3
|
| 382 |
10810
|
LAUGB
|
3
|
| 383 |
10482
|
LAZYK
|
2
|
| 384 |
10545
|
LAZYK
|
2
|
| 385 |
10279
|
LEHMS
|
15
|
| 386 |
10284
|
LEHMS
|
15
|
| 387 |
10343
|
LEHMS
|
15
|
| 388 |
10497
|
LEHMS
|
15
|
| 389 |
10522
|
LEHMS
|
15
|
| 390 |
10534
|
LEHMS
|
15
|
| 391 |
10536
|
LEHMS
|
15
|
| 392 |
10557
|
LEHMS
|
15
|
| 393 |
10592
|
LEHMS
|
15
|
| 394 |
10593
|
LEHMS
|
15
|
| 395 |
10772
|
LEHMS
|
15
|
| 396 |
10862
|
LEHMS
|
15
|
| 397 |
10891
|
LEHMS
|
15
|
| 398 |
10934
|
LEHMS
|
15
|
| 399 |
11070
|
LEHMS
|
15
|
| 400 |
10579
|
LETSS
|
4
|
| 401 |
10719
|
LETSS
|
4
|
| 402 |
10735
|
LETSS
|
4
|
| 403 |
10884
|
LETSS
|
4
|
| 404 |
10283
|
LILAS
|
14
|
| 405 |
10296
|
LILAS
|
14
|
| 406 |
10330
|
LILAS
|
14
|
| 407 |
10357
|
LILAS
|
14
|
| 408 |
10381
|
LILAS
|
14
|
| 409 |
10461
|
LILAS
|
14
|
| 410 |
10499
|
LILAS
|
14
|
| 411 |
10543
|
LILAS
|
14
|
| 412 |
10780
|
LILAS
|
14
|
| 413 |
10823
|
LILAS
|
14
|
| 414 |
10899
|
LILAS
|
14
|
| 415 |
10997
|
LILAS
|
14
|
| 416 |
11065
|
LILAS
|
14
|
| 417 |
11071
|
LILAS
|
14
|
| 418 |
10405
|
LINOD
|
12
|
| 419 |
10485
|
LINOD
|
12
|
| 420 |
10638
|
LINOD
|
12
|
| 421 |
10697
|
LINOD
|
12
|
| 422 |
10729
|
LINOD
|
12
|
| 423 |
10811
|
LINOD
|
12
|
| 424 |
10838
|
LINOD
|
12
|
| 425 |
10840
|
LINOD
|
12
|
| 426 |
10919
|
LINOD
|
12
|
| 427 |
10954
|
LINOD
|
12
|
| 428 |
11014
|
LINOD
|
12
|
| 429 |
11039
|
LINOD
|
12
|
| 430 |
10307
|
LONEP
|
8
|
| 431 |
10317
|
LONEP
|
8
|
| 432 |
10544
|
LONEP
|
8
|
| 433 |
10662
|
LONEP
|
8
|
| 434 |
10665
|
LONEP
|
8
|
| 435 |
10867
|
LONEP
|
8
|
| 436 |
10883
|
LONEP
|
8
|
| 437 |
11018
|
LONEP
|
8
|
| 438 |
10275
|
MAGAA
|
10
|
| 439 |
10300
|
MAGAA
|
10
|
| 440 |
10404
|
MAGAA
|
10
|
| 441 |
10467
|
MAGAA
|
10
|
| 442 |
10635
|
MAGAA
|
10
|
| 443 |
10754
|
MAGAA
|
10
|
| 444 |
10784
|
MAGAA
|
10
|
| 445 |
10818
|
MAGAA
|
10
|
| 446 |
10939
|
MAGAA
|
10
|
| 447 |
10950
|
MAGAA
|
10
|
| 448 |
10529
|
MAISD
|
7
|
| 449 |
10649
|
MAISD
|
7
|
| 450 |
10760
|
MAISD
|
7
|
| 451 |
10892
|
MAISD
|
7
|
| 452 |
10896
|
MAISD
|
7
|
| 453 |
10978
|
MAISD
|
7
|
| 454 |
11004
|
MAISD
|
7
|
| 455 |
10332
|
MEREP
|
13
|
| 456 |
10339
|
MEREP
|
13
|
| 457 |
10376
|
MEREP
|
13
|
| 458 |
10424
|
MEREP
|
13
|
| 459 |
10439
|
MEREP
|
13
|
| 460 |
10505
|
MEREP
|
13
|
| 461 |
10565
|
MEREP
|
13
|
| 462 |
10570
|
MEREP
|
13
|
| 463 |
10590
|
MEREP
|
13
|
| 464 |
10605
|
MEREP
|
13
|
| 465 |
10618
|
MEREP
|
13
|
| 466 |
10619
|
MEREP
|
13
|
| 467 |
10724
|
MEREP
|
13
|
| 468 |
10277
|
MORGK
|
5
|
| 469 |
10575
|
MORGK
|
5
|
| 470 |
10699
|
MORGK
|
5
|
| 471 |
10779
|
MORGK
|
5
|
| 472 |
10945
|
MORGK
|
5
|
| 473 |
10517
|
NORTS
|
3
|
| 474 |
10752
|
NORTS
|
3
|
| 475 |
11057
|
NORTS
|
3
|
| 476 |
10409
|
OCEAN
|
5
|
| 477 |
10531
|
OCEAN
|
5
|
| 478 |
10898
|
OCEAN
|
5
|
| 479 |
10958
|
OCEAN
|
5
|
| 480 |
10986
|
OCEAN
|
5
|
| 481 |
10305
|
OLDWO
|
10
|
| 482 |
10338
|
OLDWO
|
10
|
| 483 |
10441
|
OLDWO
|
10
|
| 484 |
10594
|
OLDWO
|
10
|
| 485 |
10680
|
OLDWO
|
10
|
| 486 |
10706
|
OLDWO
|
10
|
| 487 |
10808
|
OLDWO
|
10
|
| 488 |
10855
|
OLDWO
|
10
|
| 489 |
10965
|
OLDWO
|
10
|
| 490 |
11034
|
OLDWO
|
10
|
| 491 |
10260
|
OTTIK
|
10
|
| 492 |
10407
|
OTTIK
|
10
|
| 493 |
10508
|
OTTIK
|
10
|
| 494 |
10554
|
OTTIK
|
10
|
| 495 |
10580
|
OTTIK
|
10
|
| 496 |
10684
|
OTTIK
|
10
|
| 497 |
10766
|
OTTIK
|
10
|
| 498 |
10833
|
OTTIK
|
10
|
| 499 |
10999
|
OTTIK
|
10
|
| 500 |
11020
|
OTTIK
|
10
|
| 501 |
10322
|
PERIC
|
6
|
| 502 |
10354
|
PERIC
|
6
|
| 503 |
10474
|
PERIC
|
6
|
| 504 |
10502
|
PERIC
|
6
|
| 505 |
10995
|
PERIC
|
6
|
| 506 |
11073
|
PERIC
|
6
|
| 507 |
10353
|
PICCO
|
10
|
| 508 |
10392
|
PICCO
|
10
|
| 509 |
10427
|
PICCO
|
10
|
| 510 |
10489
|
PICCO
|
10
|
| 511 |
10530
|
PICCO
|
10
|
| 512 |
10597
|
PICCO
|
10
|
| 513 |
10686
|
PICCO
|
10
|
| 514 |
10747
|
PICCO
|
10
|
| 515 |
10844
|
PICCO
|
10
|
| 516 |
11053
|
PICCO
|
10
|
| 517 |
10336
|
PRINI
|
5
|
| 518 |
10397
|
PRINI
|
5
|
| 519 |
10433
|
PRINI
|
5
|
| 520 |
10477
|
PRINI
|
5
|
| 521 |
11007
|
PRINI
|
5
|
| 522 |
10261
|
QUEDE
|
9
|
| 523 |
10291
|
QUEDE
|
9
|
| 524 |
10379
|
QUEDE
|
9
|
| 525 |
10421
|
QUEDE
|
9
|
| 526 |
10587
|
QUEDE
|
9
|
| 527 |
10647
|
QUEDE
|
9
|
| 528 |
10720
|
QUEDE
|
9
|
| 529 |
10794
|
QUEDE
|
9
|
| 530 |
10989
|
QUEDE
|
9
|
| 531 |
10372
|
QUEEN
|
13
|
| 532 |
10406
|
QUEEN
|
13
|
| 533 |
10487
|
QUEEN
|
13
|
| 534 |
10637
|
QUEEN
|
13
|
| 535 |
10659
|
QUEEN
|
13
|
| 536 |
10704
|
QUEEN
|
13
|
| 537 |
10728
|
QUEEN
|
13
|
| 538 |
10786
|
QUEEN
|
13
|
| 539 |
10868
|
QUEEN
|
13
|
| 540 |
10913
|
QUEEN
|
13
|
| 541 |
10914
|
QUEEN
|
13
|
| 542 |
10961
|
QUEEN
|
13
|
| 543 |
11068
|
QUEEN
|
13
|
| 544 |
10273
|
QUICK
|
28
|
| 545 |
10285
|
QUICK
|
28
|
| 546 |
10286
|
QUICK
|
28
|
| 547 |
10313
|
QUICK
|
28
|
| 548 |
10345
|
QUICK
|
28
|
| 549 |
10361
|
QUICK
|
28
|
| 550 |
10418
|
QUICK
|
28
|
| 551 |
10451
|
QUICK
|
28
|
| 552 |
10515
|
QUICK
|
28
|
| 553 |
10527
|
QUICK
|
28
|
| 554 |
10540
|
QUICK
|
28
|
| 555 |
10549
|
QUICK
|
28
|
| 556 |
10588
|
QUICK
|
28
|
| 557 |
10658
|
QUICK
|
28
|
| 558 |
10691
|
QUICK
|
28
|
| 559 |
10694
|
QUICK
|
28
|
| 560 |
10721
|
QUICK
|
28
|
| 561 |
10745
|
QUICK
|
28
|
| 562 |
10765
|
QUICK
|
28
|
| 563 |
10788
|
QUICK
|
28
|
| 564 |
10845
|
QUICK
|
28
|
| 565 |
10865
|
QUICK
|
28
|
| 566 |
10878
|
QUICK
|
28
|
| 567 |
10938
|
QUICK
|
28
|
| 568 |
10962
|
QUICK
|
28
|
| 569 |
10991
|
QUICK
|
28
|
| 570 |
10996
|
QUICK
|
28
|
| 571 |
11021
|
QUICK
|
28
|
| 572 |
10448
|
RANCH
|
5
|
| 573 |
10716
|
RANCH
|
5
|
| 574 |
10828
|
RANCH
|
5
|
| 575 |
10916
|
RANCH
|
5
|
| 576 |
11019
|
RANCH
|
5
|
| 577 |
10262
|
RATTC
|
18
|
| 578 |
10272
|
RATTC
|
18
|
| 579 |
10294
|
RATTC
|
18
|
| 580 |
10314
|
RATTC
|
18
|
| 581 |
10316
|
RATTC
|
18
|
| 582 |
10346
|
RATTC
|
18
|
| 583 |
10401
|
RATTC
|
18
|
| 584 |
10479
|
RATTC
|
18
|
| 585 |
10564
|
RATTC
|
18
|
| 586 |
10569
|
RATTC
|
18
|
| 587 |
10598
|
RATTC
|
18
|
| 588 |
10761
|
RATTC
|
18
|
| 589 |
10820
|
RATTC
|
18
|
| 590 |
10852
|
RATTC
|
18
|
| 591 |
10889
|
RATTC
|
18
|
| 592 |
10988
|
RATTC
|
18
|
| 593 |
11000
|
RATTC
|
18
|
| 594 |
11077
|
RATTC
|
18
|
| 595 |
10288
|
REGGC
|
12
|
| 596 |
10428
|
REGGC
|
12
|
| 597 |
10443
|
REGGC
|
12
|
| 598 |
10562
|
REGGC
|
12
|
| 599 |
10586
|
REGGC
|
12
|
| 600 |
10655
|
REGGC
|
12
|
| 601 |
10727
|
REGGC
|
12
|
| 602 |
10812
|
REGGC
|
12
|
| 603 |
10908
|
REGGC
|
12
|
| 604 |
10942
|
REGGC
|
12
|
| 605 |
11010
|
REGGC
|
12
|
| 606 |
11062
|
REGGC
|
12
|
| 607 |
10287
|
RICAR
|
11
|
| 608 |
10299
|
RICAR
|
11
|
| 609 |
10447
|
RICAR
|
11
|
| 610 |
10481
|
RICAR
|
11
|
| 611 |
10563
|
RICAR
|
11
|
| 612 |
10622
|
RICAR
|
11
|
| 613 |
10648
|
RICAR
|
11
|
| 614 |
10813
|
RICAR
|
11
|
| 615 |
10851
|
RICAR
|
11
|
| 616 |
10877
|
RICAR
|
11
|
| 617 |
11059
|
RICAR
|
11
|
| 618 |
10255
|
RICSU
|
10
|
| 619 |
10419
|
RICSU
|
10
|
| 620 |
10537
|
RICSU
|
10
|
| 621 |
10666
|
RICSU
|
10
|
| 622 |
10751
|
RICSU
|
10
|
| 623 |
10758
|
RICSU
|
10
|
| 624 |
10931
|
RICSU
|
10
|
| 625 |
10951
|
RICSU
|
10
|
| 626 |
11033
|
RICSU
|
10
|
| 627 |
11075
|
RICSU
|
10
|
| 628 |
10281
|
ROMEY
|
5
|
| 629 |
10282
|
ROMEY
|
5
|
| 630 |
10306
|
ROMEY
|
5
|
| 631 |
10917
|
ROMEY
|
5
|
| 632 |
11013
|
ROMEY
|
5
|
| 633 |
10387
|
SANTG
|
6
|
| 634 |
10520
|
SANTG
|
6
|
| 635 |
10639
|
SANTG
|
6
|
| 636 |
10831
|
SANTG
|
6
|
| 637 |
10909
|
SANTG
|
6
|
| 638 |
11015
|
SANTG
|
6
|
| 639 |
10324
|
SAVEA
|
31
|
| 640 |
10393
|
SAVEA
|
31
|
| 641 |
10398
|
SAVEA
|
31
|
| 642 |
10440
|
SAVEA
|
31
|
| 643 |
10452
|
SAVEA
|
31
|
| 644 |
10510
|
SAVEA
|
31
|
| 645 |
10555
|
SAVEA
|
31
|
| 646 |
10603
|
SAVEA
|
31
|
| 647 |
10607
|
SAVEA
|
31
|
| 648 |
10612
|
SAVEA
|
31
|
| 649 |
10627
|
SAVEA
|
31
|
| 650 |
10657
|
SAVEA
|
31
|
| 651 |
10678
|
SAVEA
|
31
|
| 652 |
10700
|
SAVEA
|
31
|
| 653 |
10711
|
SAVEA
|
31
|
| 654 |
10713
|
SAVEA
|
31
|
| 655 |
10714
|
SAVEA
|
31
|
| 656 |
10722
|
SAVEA
|
31
|
| 657 |
10748
|
SAVEA
|
31
|
| 658 |
10757
|
SAVEA
|
31
|
| 659 |
10815
|
SAVEA
|
31
|
| 660 |
10847
|
SAVEA
|
31
|
| 661 |
10882
|
SAVEA
|
31
|
| 662 |
10894
|
SAVEA
|
31
|
| 663 |
10941
|
SAVEA
|
31
|
| 664 |
10983
|
SAVEA
|
31
|
| 665 |
10984
|
SAVEA
|
31
|
| 666 |
11002
|
SAVEA
|
31
|
| 667 |
11030
|
SAVEA
|
31
|
| 668 |
11031
|
SAVEA
|
31
|
| 669 |
11064
|
SAVEA
|
31
|
| 670 |
10359
|
SEVES
|
9
|
| 671 |
10377
|
SEVES
|
9
|
| 672 |
10388
|
SEVES
|
9
|
| 673 |
10472
|
SEVES
|
9
|
| 674 |
10523
|
SEVES
|
9
|
| 675 |
10547
|
SEVES
|
9
|
| 676 |
10800
|
SEVES
|
9
|
| 677 |
10804
|
SEVES
|
9
|
| 678 |
10869
|
SEVES
|
9
|
| 679 |
10341
|
SIMOB
|
7
|
| 680 |
10417
|
SIMOB
|
7
|
| 681 |
10556
|
SIMOB
|
7
|
| 682 |
10642
|
SIMOB
|
7
|
| 683 |
10669
|
SIMOB
|
7
|
| 684 |
10802
|
SIMOB
|
7
|
| 685 |
11074
|
SIMOB
|
7
|
| 686 |
10738
|
SPECD
|
4
|
| 687 |
10907
|
SPECD
|
4
|
| 688 |
10964
|
SPECD
|
4
|
| 689 |
11043
|
SPECD
|
4
|
| 690 |
10271
|
SPLIR
|
9
|
| 691 |
10329
|
SPLIR
|
9
|
| 692 |
10349
|
SPLIR
|
9
|
| 693 |
10369
|
SPLIR
|
9
|
| 694 |
10385
|
SPLIR
|
9
|
| 695 |
10432
|
SPLIR
|
9
|
| 696 |
10756
|
SPLIR
|
9
|
| 697 |
10821
|
SPLIR
|
9
|
| 698 |
10974
|
SPLIR
|
9
|
| 699 |
10252
|
SUPRD
|
12
|
| 700 |
10302
|
SUPRD
|
12
|
| 701 |
10458
|
SUPRD
|
12
|
| 702 |
10463
|
SUPRD
|
12
|
| 703 |
10475
|
SUPRD
|
12
|
| 704 |
10767
|
SUPRD
|
12
|
| 705 |
10841
|
SUPRD
|
12
|
| 706 |
10846
|
SUPRD
|
12
|
| 707 |
10885
|
SUPRD
|
12
|
| 708 |
10930
|
SUPRD
|
12
|
| 709 |
11035
|
SUPRD
|
12
|
| 710 |
11038
|
SUPRD
|
12
|
| 711 |
10310
|
THEBI
|
4
|
| 712 |
10708
|
THEBI
|
4
|
| 713 |
10805
|
THEBI
|
4
|
| 714 |
10992
|
THEBI
|
4
|
| 715 |
10624
|
THECR
|
3
|
| 716 |
10775
|
THECR
|
3
|
| 717 |
11003
|
THECR
|
3
|
| 718 |
10249
|
TOMSP
|
6
|
| 719 |
10438
|
TOMSP
|
6
|
| 720 |
10446
|
TOMSP
|
6
|
| 721 |
10548
|
TOMSP
|
6
|
| 722 |
10608
|
TOMSP
|
6
|
| 723 |
10967
|
TOMSP
|
6
|
| 724 |
10276
|
TORTU
|
10
|
| 725 |
10293
|
TORTU
|
10
|
| 726 |
10304
|
TORTU
|
10
|
| 727 |
10319
|
TORTU
|
10
|
| 728 |
10518
|
TORTU
|
10
|
| 729 |
10576
|
TORTU
|
10
|
| 730 |
10676
|
TORTU
|
10
|
| 731 |
10842
|
TORTU
|
10
|
| 732 |
10915
|
TORTU
|
10
|
| 733 |
11069
|
TORTU
|
10
|
| 734 |
10292
|
TRADH
|
6
|
| 735 |
10496
|
TRADH
|
6
|
| 736 |
10606
|
TRADH
|
6
|
| 737 |
10830
|
TRADH
|
6
|
| 738 |
10834
|
TRADH
|
6
|
| 739 |
10839
|
TRADH
|
6
|
| 740 |
10574
|
TRAIH
|
3
|
| 741 |
10577
|
TRAIH
|
3
|
| 742 |
10822
|
TRAIH
|
3
|
| 743 |
10367
|
VAFFE
|
11
|
| 744 |
10399
|
VAFFE
|
11
|
| 745 |
10465
|
VAFFE
|
11
|
| 746 |
10591
|
VAFFE
|
11
|
| 747 |
10602
|
VAFFE
|
11
|
| 748 |
10688
|
VAFFE
|
11
|
| 749 |
10744
|
VAFFE
|
11
|
| 750 |
10769
|
VAFFE
|
11
|
| 751 |
10921
|
VAFFE
|
11
|
| 752 |
10946
|
VAFFE
|
11
|
| 753 |
10994
|
VAFFE
|
11
|
| 754 |
10251
|
VICTE
|
10
|
| 755 |
10334
|
VICTE
|
10
|
| 756 |
10450
|
VICTE
|
10
|
| 757 |
10459
|
VICTE
|
10
|
| 758 |
10478
|
VICTE
|
10
|
| 759 |
10546
|
VICTE
|
10
|
| 760 |
10806
|
VICTE
|
10
|
| 761 |
10814
|
VICTE
|
10
|
| 762 |
10843
|
VICTE
|
10
|
| 763 |
10850
|
VICTE
|
10
|
| 764 |
10248
|
VINET
|
5
|
| 765 |
10274
|
VINET
|
5
|
| 766 |
10295
|
VINET
|
5
|
| 767 |
10737
|
VINET
|
5
|
| 768 |
10739
|
VINET
|
5
|
| 769 |
10301
|
WANDK
|
10
|
| 770 |
10312
|
WANDK
|
10
|
| 771 |
10348
|
WANDK
|
10
|
| 772 |
10356
|
WANDK
|
10
|
| 773 |
10513
|
WANDK
|
10
|
| 774 |
10632
|
WANDK
|
10
|
| 775 |
10640
|
WANDK
|
10
|
| 776 |
10651
|
WANDK
|
10
|
| 777 |
10668
|
WANDK
|
10
|
| 778 |
11046
|
WANDK
|
10
|
| 779 |
10266
|
WARTH
|
15
|
| 780 |
10270
|
WARTH
|
15
|
| 781 |
10320
|
WARTH
|
15
|
| 782 |
10333
|
WARTH
|
15
|
| 783 |
10412
|
WARTH
|
15
|
| 784 |
10416
|
WARTH
|
15
|
| 785 |
10437
|
WARTH
|
15
|
| 786 |
10455
|
WARTH
|
15
|
| 787 |
10526
|
WARTH
|
15
|
| 788 |
10553
|
WARTH
|
15
|
| 789 |
10583
|
WARTH
|
15
|
| 790 |
10636
|
WARTH
|
15
|
| 791 |
10750
|
WARTH
|
15
|
| 792 |
10781
|
WARTH
|
15
|
| 793 |
11025
|
WARTH
|
15
|
| 794 |
10256
|
WELLI
|
9
|
| 795 |
10420
|
WELLI
|
9
|
| 796 |
10585
|
WELLI
|
9
|
| 797 |
10644
|
WELLI
|
9
|
| 798 |
10803
|
WELLI
|
9
|
| 799 |
10809
|
WELLI
|
9
|
| 800 |
10900
|
WELLI
|
9
|
| 801 |
10905
|
WELLI
|
9
|
| 802 |
10935
|
WELLI
|
9
|
| 803 |
10269
|
WHITC
|
14
|
| 804 |
10344
|
WHITC
|
14
|
| 805 |
10469
|
WHITC
|
14
|
| 806 |
10483
|
WHITC
|
14
|
| 807 |
10504
|
WHITC
|
14
|
| 808 |
10596
|
WHITC
|
14
|
| 809 |
10693
|
WHITC
|
14
|
| 810 |
10696
|
WHITC
|
14
|
| 811 |
10723
|
WHITC
|
14
|
| 812 |
10740
|
WHITC
|
14
|
| 813 |
10861
|
WHITC
|
14
|
| 814 |
10904
|
WHITC
|
14
|
| 815 |
11032
|
WHITC
|
14
|
| 816 |
11066
|
WHITC
|
14
|
| 817 |
10615
|
WILMK
|
7
|
| 818 |
10673
|
WILMK
|
7
|
| 819 |
10695
|
WILMK
|
7
|
| 820 |
10873
|
WILMK
|
7
|
| 821 |
10879
|
WILMK
|
7
|
| 822 |
10910
|
WILMK
|
7
|
| 823 |
11005
|
WILMK
|
7
|
| 824 |
10374
|
WOLZA
|
7
|
| 825 |
10611
|
WOLZA
|
7
|
| 826 |
10792
|
WOLZA
|
7
|
| 827 |
10870
|
WOLZA
|
7
|
| 828 |
10906
|
WOLZA
|
7
|
| 829 |
10998
|
WOLZA
|
7
|
| 830 |
11044
|
WOLZA
|
7
|
4. Usage of COUNT_BIG with DISTINCT to find distinct supplier
SQL Server Query 5
-- Find distinct count of suppliers
SELECT
COUNT_BIG(DISTINCT SupplierID) AS NumberOfSuppliers
FROM
Suppliers;
Create SQL query with SqlQueryBuilder 5
var (sql5, parameters5) = new SqlQueryBuilder()
.Select()
.Column(new COUNT_BIG(new Column("SupplierID"), true), "NumberOfSuppliers")
.From("Suppliers")
.Build();
Query build by SqlQueryBuilder 5
SELECT COUNT(DISTINCT SupplierID) AS NumberOfSuppliers
FROM Suppliers;
Parameters (If used)
Query Results 5: