Hi guys,
I need assistance for this kind of sql result. I'm quite inexperienced with aggregate functions and grouping data after a selection. So here is what I get from my query so far:
Year Total Format
-------------------------------
2002 1341 PDF
2002 77 PALM
2002 1 AUDIO
2003 6596 PDF
2003 381 PALM
2003 3 AUDIO
2003 53 MSR
Indeed, what I'd like to have is such a result:
What I would like to achieve is this kind of bag:
Year PDF PALM AUDIO MSR ... ...
2002 1341 77 1 n/a
2003 6596 381 3 53 ... ...
And here's the sql:
SELECT Year(sendDate) as MonthYear, COUNT(abstractTypeId) AS CountAbstractTypes, masterDataAbstractTypes.name as Format FROM masterDataAbstractTypes INNER JOIN downloadHistory ON downloadHistory.abstractTypeId = masterDataAbstractTypes.id GROUP BY Year(sendDate),abstractTypeId order by MonthYear
I need assistance for this kind of sql result. I'm quite inexperienced with aggregate functions and grouping data after a selection. So here is what I get from my query so far:
Year Total Format
-------------------------------
2002 1341 PDF
2002 77 PALM
2002 1 AUDIO
2003 6596 PDF
2003 381 PALM
2003 3 AUDIO
2003 53 MSR
Indeed, what I'd like to have is such a result:
What I would like to achieve is this kind of bag:
Year PDF PALM AUDIO MSR ... ...
2002 1341 77 1 n/a
2003 6596 381 3 53 ... ...
And here's the sql:
SELECT Year(sendDate) as MonthYear, COUNT(abstractTypeId) AS CountAbstractTypes, masterDataAbstractTypes.name as Format FROM masterDataAbstractTypes INNER JOIN downloadHistory ON downloadHistory.abstractTypeId = masterDataAbstractTypes.id GROUP BY Year(sendDate),abstractTypeId order by MonthYear