Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql syntax
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01171866
Message ID:
01171883
Views:
6
>Hello.
>I have 1 purchase order that creates two jobs Master and Child for each stock code.
>
>Each job uses different resources to create it's output.
>
>What i'm trying to do with this sql sentence is to show the resources needed for each stock in the purchase order, but i don't know how to make the join of the Job2.
>
>Thank you for your time.
>
>select a.SalesOrder, a.MStockCode, a.MStockDes, a.MOrderQty, b.Job,
>(select Job from WipMaster where JobMaestro = b.Job) as Job2,
>c.MStockCode as Insumos,c.MDescription as NombreInsumo, c.MQtyIssued as CantidadInsumo,
>d.MStockCode as Insumos2,d.MDescription as NombreInsumo2,d.MQtyIssued as CantidadInsumo2
>from SorDetail as a
>left join WipMaster as b on a.SalesOrder=b.SalesOrder and a.SalesOrderLine= b.SalesOrderLine
>left join WipJobPost as c on b.Job = c.Job
>
>left join WipJobPost as d on d.Job = Job2 <- HOW DO I TELL: USE THE JOB2 COLUMN
>
>where a.SalesOrder = 155 and Left(c.MStockCode,1) <> 'C' and c.TrnType = 'R'



Not sure, because I couldn't test it, but try:
 select a.SalesOrder,;
        a.MStockCode,;
        a.MStockDes,;
        a.MOrderQty,;
        b.Job,;
        j2.Job AS Job2,;
        c.MStockCode as Insumos,;
        c.MDescription as NombreInsumo,;
        c.MQtyIssued as CantidadInsumo,;
        d.MStockCode as Insumos2,;
        d.MDescription as NombreInsumo2,;
        d.MQtyIssued as CantidadInsumo2;
from SorDetail as a
left join WipMaster  as b  on a.SalesOrder=b.SalesOrder and a.SalesOrderLine= b.SalesOrderLine;
left join WipJobPost as c  on b.Job = c.Job;
left join WipMaster  as b2 on b.Job=b2.JobMaestro;
left join WipJobPost as d on d.Job = b2.Job;
where a.SalesOrder = 155 and Left(c.MStockCode,1) <> 'C' and c.TrnType = 'R'
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform