Cube Question...I think

  • 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

  • Example please?

    Show current output and desired output.

    /Kenneth

  • Current output:

    WorkOrderID PermitEst  PermitProcEst   techAudEst FreightEst ElectricalEst RemDispEst WallRepEst TaxEst
    525031032536512506975951892.32
    600000000
    700000000
    925031032536720007974151308.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.

  • 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

  • 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