October 11, 2005 at 5:19 pm
When I run the below query, I get back 5 rows of information...4 rows showing each workorderid, and a summary row summarizing each column. Is there a way to write a query that will return the 4 rows into one row and summarize the row as opposed to summarizing the columns?
Select sum(permitest) As PermitEst, sum(PermitProcEst) As PermitProcEst, Sum(techaudEst) As techAudEst, sum(FreightEst) As FreightEst, sum(ElectricalEst) As ElectricalEst, sum(RemDispEst) As RemDispEst, sum(WallRepEst) As WallRepEst, sum(TaxEst) As TaxEst From WorkOrders Where workorderid In (13, 14, 15, 16)
group by workorderid with cube
October 12, 2005 at 7:30 am
Example please?
Show current output and desired output.
/Kenneth
October 12, 2005 at 7:53 am
Current output:
WorkOrderID | PermitEst | PermitProcEst | techAudEst | FreightEst | ElectricalEst | RemDispEst | WallRepEst | TaxEst |
5 | 250 | 310 | 325 | 365 | 1250 | 697 | 595 | 1892.32 |
6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
9 | 250 | 310 | 325 | 367 | 2000 | 797 | 415 | 1308.48 |
Desired output:
I would like to change the above output to return only one row with all four records combined into one, as the four records are all related to one overall workorder. It would be the same for all other workorders in my table (4 records that need to be combined).
Hope this helps. I have come to the conclusion though that combining this on the front end would probably be better though. Any thoughts here? Thanks for your help.
October 12, 2005 at 10:13 am
Just comment out the group by !?!
Select sum(permitest) As PermitEst
, sum(PermitProcEst) As PermitProcEst
, Sum(techaudEst) As techAudEst
, sum(FreightEst) As FreightEst
, sum(ElectricalEst) As ElectricalEst
, sum(RemDispEst) As RemDispEst
, sum(WallRepEst) As WallRepEst
, sum(TaxEst) As TaxEst
From
WorkOrders
Where
workorderid In (13, 14, 15, 16)
--group by workorderid with cube
* Noel
October 13, 2005 at 1:40 am
Yes, that would maybe do it? If all you need is the overall sum, you can omit the separate workorder id's..?
/Kenneth
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply