473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Using Crosstab Query In PHP For further summing details

190 100+
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
0 1257

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

Similar topics

3
by: Darleen | last post by:
I am seeking conceptual here on how to get started with a "3D Matrix" in Access. We run a training center which holds multiple classes in multiple cities at multiple times. So I need to create a...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
2
by: Sherman H. | last post by:
I have a few questions for crosstab and popup form questions: 1. I created a crosstab as follows: IT Financial Operation John 21 22 ...
1
by: Paula | last post by:
A query contains the fields CustomerID, CustomerName, OrderID and ItemID. The query is based on a customers table, orders table, and order details table. The orders table has a foreign key of...
3
by: Bryan | last post by:
I've been looking over this newsgroup, but I can't find an answer to my problem. I see that a few others have posted this issue over the years, but none of them got a response. I'll give it...
7
by: newguy | last post by:
I am trying to get the totals of a table by client by type of income. This query will get what I am looking for with each unique combination as a row: SELECT Sales.Client, BillCode.Type,...
8
by: Penny | last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro) Hi All, I would really appreciate just some basic tips on how to make a Crosstab Form based on a Crosstab Query. The query always has the same...
2
by: Mike | last post by:
Hi everyone, I found the Access reports too limited to do what i wanted so i created a module to export a crosstab query to an excel file, and then i modify it as i want. My problem is that i...
0
by: Peter Herath | last post by:
I want to create a custormizable report . For an example, there's a form with four combo boxes and two of them having database tables columns/field names as values in the combo box(one for select row...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.