-
SQL Gurus again
Trying to write an join for ADO.NET and ODBC.
I need to outer join three tables and do an In on the first table, is this possible to do in one statement?
I basically want to combine these two statements:
SELECT BI_ACCT, BI_SRV_STAT_CD, BI_DNP_SW FROM BI_TYPE_SERVICE WHERE BI_SRV_STAT_CD IN(1,3,7,18,19,21,22,25,26,29,30,42,45)
SELECT t.BI_ACCT, t.BI_SRV_STAT_CD, t.BI_DNP_SW, a.BI_VWN_TOT_AR, c.BI_OUTAGE_PRI_CD, c.BI_MED_NEC_CD, c.CC_NBR, c.BI_SRV_LOC_NBR FROM (BI_TYPE_SERVICE t LEFT JOIN BI_AR_TOTALS_VIEW_1 a ON t.BI_ACCT = a.BI_ACCT) LEFT JOIN BI_CONSUMER c ON t.BI_ACCT = c.BI_ACCT
Will the following give me the data I need? I mean it "works", but I'm not positive I'm getting the correct dataset.
SELECT t.BI_ACCT, t.BI_SRV_STAT_CD, t.BI_DNP_SW, a.BI_VWN_TOT_AR, c.BI_OUTAGE_PRI_CD, c.BI_MED_NEC_CD, c.CC_NBR, c.BI_SRV_LOC_NBR FROM (BI_TYPE_SERVICE t LEFT JOIN BI_AR_TOTALS_VIEW_1 a ON t.BI_ACCT = a.BI_ACCT) LEFT JOIN BI_CONSUMER c ON t.BI_ACCT = c.BI_ACCT WHERE t.BI_SRV_STAT_CD IN(1,3,7,18,19,21,22,25,26,29,30,42,45)
thanks for any help...
-
why not use server exploer to design the view, you can then check whether works using your selection criteria and if required cut and paste the generated sql statement into your own code.