Results 1 to 2 of 2

Thread: SQL Gurus again

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    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...
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width