General discussion

Locked

Fault that joins between multiple tables

By lsuersoy ·
Hi, I'm a problem I had .5 relationship between different tables. I need to add more to this relationship a table. Thus, the relationship between the table I will have six. In the first table, and sixth in the table in question is not data. The name of the sixth LG_086_PRICE table. I was in the first table, the sixth in the table do not want to come to the data value is NULL. I'm very weak in joins. Thanks to what might help. Ersoy Aydın System Specialist LBS.

Code with the following six statements, incorrect number brings the data. In this case there are errors in the code join. But I do not know the solution.

SELECT SIPFIS.DATE_ AS Tarih, SIPFIS.TIME_ AS Saat, SIPFIS.FICHENO AS Sipariş_No, STOK.PRODUCERCODE AS Barkodu, STOK.CODE AS [Stok Kodu],
STOK.NAME AS [Stok Adı], SIPSATIR.AMOUNT AS Miktar, LG_086_01_GNTOTST.ONHAND AS [Eldeki Miktar], SIPSATIR.PRICE AS [SATIŞ BR.Fiyat],
LG_086_PRCLIST.PRICE AS [Liste Fiyatı], SIPSATIR.VATMATRAH / SIPSATIR.AMOUNT AS [NET SATIŞ BR.Fiyat], SIPSATIR.TOTAL AS ,
SIPSATIR.VATMATRAH AS [Net Tutar],
(SELECT TOP 1 OUTREMCOST
FROM LG_086_01_STLINE
WHERE STOCKREF = STOK.LOGICALREF AND (TRCODE = 51 OR
TRCODE = 8 OR
TRCODE = 1) AND OUTREMCOST <> 0 AND LPRODSTAT = 0 AND LINETYPE = 0
ORDER BY DATE_ DESC) AS BrMaliyet, SIPSATIR.AMOUNT *
(SELECT TOP 1 OUTREMCOST
FROM LG_086_01_STLINE
WHERE STOCKREF = STOK.LOGICALREF AND (TRCODE = 51 OR
TRCODE = 8 OR
TRCODE = 1) AND OUTREMCOST <> 0 AND LPRODSTAT = 0 AND LINETYPE = 0
ORDER BY DATE_ DESC) AS [Toplam Maliyet], SIPSATIR.VATMATRAH - SIPSATIR.AMOUNT *
(SELECT TOP 1 OUTREMCOST
FROM LG_086_01_STLINE
WHERE STOCKREF = STOK.LOGICALREF AND (TRCODE = 51 OR
TRCODE = 8 OR
TRCODE = 1) AND OUTREMCOST <> 0 AND LPRODSTAT = 0 AND LINETYPE = 0
ORDER BY DATE_ DESC) AS NETKAR
FROM
LG_086_ITEMS STOK INNER JOIN
LG_086_01_ORFLINE SIPSATIR ON STOK.LOGICALREF = SIPSATIR.STOCKREF INNER JOIN
LG_086_PRCLIST ON STOK.LOGICALREF = LG_086_PRCLIST.CARDREF RIGHT OUTER JOIN
LG_086_01_ORFICHE SIPFIS ON SIPSATIR.ORDFICHEREF = SIPFIS.LOGICALREF LEFT OUTER JOIN
LG_086_01_GNTOTST ON SIPSATIR.STOCKREF = LG_086_01_GNTOTST.STOCKREF
WHERE (SIPFIS.FICHENO = '00076166') AND (LG_086_01_GNTOTST.INVENNO = 0) AND (LG_086_PRCLIST.PTYPE = 2)

Thanks for your help.

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Back to Windows Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums