By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 883 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Using Crosstab Query In PHP For further summing details

100+
P: 190
I have a crosstab query having grouping in 3 levels and i need to summup and disply total ....

how can i go about it
i m pasting my query
Expand|Select|Wrap|Line Numbers
  1.  
  2. $sql = 'select `main_state`,`state_name`,`gender`,'
  3.         . ' sum(if(nature_of_injury = 10,1,0)) as N10,'
  4.         . ' sum(if(nature_of_injury = 15,1,0)) as N15,'
  5.         . ' sum(if(nature_of_injury = 20,1,0)) as N20,'
  6.         . ' sum(if(nature_of_injury = 25,1,0)) as N25,'
  7.         . ' sum(if(nature_of_injury = 30,1,0)) as N30,'
  8.         . ' sum(if(nature_of_injury = 35,1,0)) as N35,'
  9.         . ' sum(if(nature_of_injury = 40,1,0)) as N40,'
  10.         . ' sum(if(nature_of_injury = 45,1,0)) as N45,'
  11.         . ' sum(if(nature_of_injury = 50,1,0)) as N50,'
  12.         . ' sum(if(nature_of_injury = 55,1,0)) as N55,'
  13.         . ' sum(if(nature_of_injury = 60,1,0)) as N60,'
  14.         . ' sum(if(nature_of_injury = 65,1,0)) as N65,'
  15.         . ' sum(if(nature_of_injury = 70,1,0)) as N70,'
  16.         . ' sum(if(nature_of_injury = 75,1,0)) as N75 '
  17.         . ' from esicinjury group by main_state , state_name , gender ';
  18.  
This query gives me total record for each gender in each state gropuped by main_state ....and nature of injury in a column heading .....

i want sum(male) , sum(female) of all states in main_state on top as soon as main state changes .....


can you help .........
Jan 7 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.