i have below table(company_details) in oracle 10g.
state company_name avg_sal kn goo $5500 in scope $6000 ar fb $8250 cl pal $4500 cl goo $6000 ar goo $7000 in fb $3999 i form output shown below , display in simple gwt datagrid.
state count(goo) avg_sal count(scope) avg_sal count(fb) avg_sal count(pal) avg_sal kn 1 5500 -- -- -- -- -- -- in -- -- 1 6000 1 3999 -- -- ar 1 7000 -- -- 1 8250 -- -- cl 1 6000 -- -- -- -- 1 4500 i tried writing below query didn't work. kindly help
select state, count(*)as "goo_records", to_char(sum(average_sal),'$999,999') "goo_avgsal" company_details company_status = 'open' , company_name = 'goo' group state order state union select state, count(*)as "fb_records", to_char(sum(average_sal),'$999,999') "fb_avgsal" company_details company_status = 'open' , company_name = 'fb' group state order state any appreciated. in advance!!!!
try this:
select state, goocount, goocount / total avg_goo, scopecount, scopecount / total avg_scope, fbcount, fbcount / total avg_fb, palcount, palcount / total avg_pal ( select state, sum(case when company_name = 'goo' 1 else 0 end) goocount, sum(case when company_name = 'scope' 1 else 0 end) scopecount, sum(case when company_name = 'fb' 1 else 0 end) fbcount, sum(case when company_name = 'pal' 1 else 0 end) palcount, count(*) total company_details company_status = 'open' group state order state ) sub;
Comments
Post a Comment