enrique_aeo
asked on
query resumen
Hol experts, I have a table inthe database with 3 columns (observanciaRegistro, manejoGramatical, utilizacionFormalismos).
Each of these columns can have the values 1-5.
I need to do a query to tell me the number of times under the number 1, number 2, etc
I attached two files data and query
number.JPG
reporte-deseado.JPG
Each of these columns can have the values 1-5.
I need to do a query to tell me the number of times under the number 1, number 2, etc
I attached two files data and query
number.JPG
reporte-deseado.JPG
p.s. in order to get result same as your image, you may need to change
PIVOT (SUM(CNT) FOR [Score] IN ([1],[2],[3],[4],[5])) P
to be
PIVOT (SUM(CNT) FOR [Score] IN ([5],[4],[3],[2],[1])) P
PIVOT (SUM(CNT) FOR [Score] IN ([1],[2],[3],[4],[5])) P
to be
PIVOT (SUM(CNT) FOR [Score] IN ([5],[4],[3],[2],[1])) P
ASKER
it is working, But, instead of null 0 I want it...
null.JPG
null.JPG
an NVL() or DECODE() might do the trick.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT * FROM
(
UNION ALL
SELECT 'manejoGramatical' , manejoGramatical, Count(*) FROM [tablename] GROUP BY manejoGramatical
UNION ALL
SELECT 'utilizacionFormalismos', utilizacionFormalismos, Count(*) FROM [tablename] GROUP BY utilizacionFormalismos
PIVOT (SUM(CNT) FOR [Score] IN ([1],[2],[3],[4],[5])) P