Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not Sure How TO Do This JOIN
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Not Sure How TO Do This JOIN
Miscellaneous
Thread ID:
01325223
Message ID:
01325223
Views:
62
I have this query:
     SELECT	tp.sTP_Name1 AS AcctName,
		t.iTrading_Partner_ID AS CustNum,
		CASE t.sTran_Group_CD
			WHEN 'MAR' THEN 'MARGIN'
			WHEN 'PHY' THEN 'PHYSICAL'
			WHEN 'FUT' THEN 'FUTURES'
			WHEN 'FOR' THEN 'FORWARDS'
			WHEN 'REP' THEN 'REPO'
			WHEN 'CON' THEN 'CONSIGNMENT'
			WHEN 'SCR' THEN 'SCRAP'
			WHEN 'PRO' THEN 'PROVISIONAL PRICING'
			WHEN 'PL'  THEN 'POOL METAL'
			ELSE ''
		END AS TranGroup,
		dtTrade_DT AS TradeDate,
		iOrder_Hdr_ID AS OrdNum,
		iTrade_ID AS TR_Number,
		sTrade_Type_CD AS TradeType,
		sProduct_CD AS Product,
		decTrade_Qty AS Quantity,
		decTrade_Unit_Price AS Price,
		decTrade_Qty * decTrade_Unit_Price AS NetAmount,
		decTrade_Cash_Balance AS CashBalance,
		decTrade_Product_Balance AS ProductBal,

-- I want to put "'Y' AS Invoiced" here if an Invoice_Hdr record exists
		
                iTrade_Conf_No AS Conf_Num
	FROM Trade t
	JOIN Trading_Partner tp ON tp.iTrading_Partner_ID = t.iTrading_Partner_ID
	JOIN Invoice_Hdr i ON i.iOrder_Hdr_id =  t.iOrder_Hdr_id
	WHERE t.decTrade_Product_Balance <> 0 OR
		  t.decTrade_Cash_Balance <> 0
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform