Reputation: 2526
How can you make a query in MS Access, so that the fields are grouped into columns?
It is easier to explain through an example.
Table:
Brand Quantity Date
1. MTZ 3 2012.03
2. MTZ 1 2012.03
3. Belor. 2 2012.04
4. YTO 2 2012.04
5. YTO 1 2013.03
I want a query like this:
Brand 2012.03 2012.04 2013.03
MTZ 4 0 0
Belor. 0 2 0
YTO 0 2 1
Upvotes: 2
Views: 67
Reputation: 199
Or you can use 'Oleddbreader' for reading each record and formating it the way you want
command.excutereader for excuting query fill data in reader and use loop to print data the way you want, you can use column by column name you sum the numeric data, you can alot of tricks with Reader Command
Upvotes: 0
Reputation: 4487
Try like this
TRANSFORM Sum(tabl1.[Quantity]) AS SumOfQuantity
SELECT tabl1.[brand], Sum( tabl1.[Quantity]) AS [Total Of Quantity]
FROM tabl1
GROUP BY tabl1.[brand]
PIVOT tabl1.[Date];
Upvotes: 1