I'm using Netezza to generate a report and I have the following query
select b.group_name,a.group_id, PASS_FAIL, COUNT(*) from log a
join group b on a.group_id=b.group_id
group by b.group_name,a.group_id, PASS_FAIL
It collects information on the number of passes and failures in a table like this:
GROUP_NAME GROUP_ID PASS_FAIL COUNT
GROUP1 4 FAIL 382
GROUP1 4 PASS 339
How can I change the query so that I can use PASS and FAIL as the columns.
GROUP_NAME GROUP_ID PASS FAIL
GROUP1 4 339 382
Pivot isn't available in Netezza so I was wondering what the best way to go about this would be. What is the best way to do this?
I don't have direct experience with netezza but from what I've read it supports the standard SQL solution of SUM/CASE
Just do a self-join of modified versions of your query above, each of which produces one of the
pass
andfail
columns that you need (note that I haven't tested this since I don't have an installation of Netezza to work with):