This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Thursday, April 9, 2009
Transpose SQL-Server For sales data F4211
Select abac11,sdtrdj,sdglc,sddcto,sdshan,rtrim(wwgnnm)+' '+wwsrnm OwnerName,
SO_INCO= CASE WHEN SDDCTO='SO' and sdglc='INCO' Then Cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
SO_INPR= CASE WHEN SDDCTO='SO' and sdglc='INPR' Then Cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
SO_INCL= CASE WHEN SDDCTO='SO' and sdglc='INCL' Then Cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
SO_INEB= CASE WHEN SDDCTO='SO' and sdglc='INEB' Then Cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
SO_INC4= CASE WHEN SDDCTO='SO' and sdglc='INC4' Then Cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
SO_INQU= CASE WHEN SDDCTO='SO' and sdglc='INQU' Then Cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
TotalSO= CASE WHEN SDDCTO='SO' and sdglc in ('INPR','INEB','INC4','INCO','INCL','INQU')Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
SA_INCO= CASE WHEN SDDCTO='SA' and sdglc='INCO' Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
SA_INPR= CASE WHEN SDDCTO='SA' and sdglc='INPR' Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
TotalSA= CASE WHEN SDDCTO='SA' and sdglc in ('INPR','INCO')Then cast(sum(sdaexp/100) as decimal(10,2)) else 0 End,
SF_INCO= CASE WHEN SDDCTO='SF' and sdglc='INCO' Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
SF_INPR= CASE WHEN SDDCTO='SF' and sdglc='INPR' Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
SF_INCL= CASE WHEN SDDCTO='SF' and sdglc='INCL' Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
SF_INEB= CASE WHEN SDDCTO='SF' and sdglc='INEB' Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End,
TotalSO= CASE WHEN SDDCTO='SF' and sdglc in ('INEB','INCO','INCL','INPR')Then Cast(sum(sdaexp/100)as decimal(10,2)) else 0 End
from proddta.f4211
left outer join proddta.f0111 on wwan8=sdshan
left outer join proddta.f0101 on aban8=sdshan
where sdnxtr=999 and sdlttr<>980 and sdkcoo=600 and sdlnty='S' and sddcto in('SO','SA','SF')
group by abac11,sdshan,wwgnnm,wwsrnm,sdtrdj,sdglc,sddcto
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment