Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with SQL statement
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01403892
Message ID:
01403925
Views:
26
>>Hi Borisloav,
>>I agree on the aliasing part. I did this for simplicity. I can change to be more descriptive.
>>The question is: do you think this effect the query in any way or is this a style issue? I am looking solving this problem. Your comments on aliases is noted.
>>thanks,
>>Alp
>
>
>Based on Yuri's answer:
>
>Select Qlp.*,;
>       EofYr.rsc,;
>       EofYr.eor,;
>       EofYr.wgc,;
>      '2P + DE - DF' as Lrdt,; 
>       EofYr.Amt - ReimbDE.Amt - ReimbDF.Amt AS LCol,;
>       EofPr.Rdt,;
>       EofPr.Amt AS RCol;
>From Qlp-All Qlp
>Left Join (select verlvlkey,;
>                  SUM(Amt) AS Amt,;
>                  MAX(Rsc) AS Rsc,;
>                  MAX(Wgc) AS Wgc;
>           from EndofYear;
>           where RDT = '2P';
>           GROUP BY verlvlkey) EofYr On EofYr.verlvlkey = Qlp.verlvlkey+'2P'+ Qlp.recordtype;
>Left Join (select verlvlkey,;
>                  SUM(Amt) AS Amt;
>           from Reimbursements;
>           where RDT = 'DE';
>           GROUP BY verlvlkey) ReimbDE On ReimbDE.verlvlkey = Qlp.verlvlkey+'DE'+ Qlp.recordtype;
>Left Join (select verlvlkey,;
>                  SUM(Amt) AS Amt;
>           from Reimbursements;
>           where RDT = 'DF'
>           GROUP BY verlvlkey) ReimbDF On ReimbDF.verlvlkey = Qlp.verlvlkey+'DF'+ Qlp.recordtype;
>Left Join (select verlvlkey,;
>                  SUM(Amt) AS Amt,;
>                  MAX(Rdt) AS Rdt;
>           from EndofPeriod;
>           where RDT = 'DH';
>           GROUP BY verlvlkey) EofPr On EofPr.verlvlkey = Qlp.verlvlkey+'DH'+ Qlp.recordtype
>
>
>NOT TESTED!!!!

Yes, I was thinking along the same lines too.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform