1,105,534 Community Members

sql formula

Member Avatar
cyberdaemon
Junior Poster
125 posts since Nov 2010
Reputation Points: 1 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Good day,
I am having a probem with my sql. I want to create a formula for my pivot field.. here is my code...

SELECT
        *

FROM 
    (
        SELECT 
            REPORT.MATERIAL
            ,REPORT.Description
            ,REPORT.Material_Type
            ,REPORT.ATP_check
            ,REPORT.Delivering_Plant
            ,REPORT.Order_Quantity
            ,REPORT.Held_by_Finance
            ,REPORT.Rejected_OOS
            ,REPORT.Rejected_Others
            ,REPORT.Open_Order_Quantity
            ,REPORT.Order_Quantity_NKA
            ,REPORT.Order_Quantity_RKA
            ,REPORT.Order_Quantity_Others
            ,REPORT.Stock
            ,REPORT.DSD_Delivery
            ,REPORT.OUtBound_Haulage
            ,REPORT.Total_OutBound_items
            ,REPORT.InBound_Haulage
            ,REPORT.Haulage_In_Transit
            ,REPORT.Process_Order
            ,REPORT.Total_Inbound_Items
            ,REPORT.Custom_Haulage_In_Transit
            ,REPORT.Custom_Inbound_Haulage
            ,REPORT.Custom_Process_Order
            ,REPORT.Custom_Total_Inbound
            ,REPORT.Custom_ATP_Quantity 
            ,TYPES.*

            FROM CO09_Report REPORT
                INNER JOIN TBLTYPES TYPES
                    ON REPORT.MATERIAL = SUBSTRING(TYPES.TXTMATERIAL,13,18)

--WHERE REPORT.Custom_ATP_Quantity >  0 


    )AS T
PIVOT (SUM(PERCENTAGE)
    FOR [TYPE] IN ([IN TRANSIT], [HAULAGE], [PRODUCTION]))
    AS pvt 

my problem is that how can i multiply REPORT.Haulage_In_Transit to [IN TRANSIT] that is located in the pivot
can anyone has an idea about this..?

thanks

Member Avatar
BitBlt
Practically a Posting Shark
895 posts since Feb 2011
Reputation Points: 442 [?]
Q&As Helped to Solve: 163 [?]
Skill Endorsements: 16 [?]
Featured
 
0
 

You could always create a temp table to hold the results of your pivot, then join that back to your original table...if I understand what you're asking for, that is.

Member Avatar
cyberdaemon
Junior Poster
125 posts since Nov 2010
Reputation Points: 1 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

anyways, i already done this, i just inserted another select at the top of the queries from thier i created the formula.

thanks BitBit for suggestion..

Question Answered as of 1 Year Ago by BitBlt
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: