+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Valued Forum Contributor pr4t3ek's Avatar
    Join Date
    10-14-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007
    Posts
    471

    Query to Show 0 if no match found

    Hi,
    I have the following SQL code:

    I would like to know if there is a way to bring back a "0" if no matches are found for all the items in the "DOBTable" table.

    Code:
    SELECT DISTINCT Name, DOB
    FROM NameTable INNER JOIN DOBTable ON DOBTable.Name = NameTable.Name
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  2. #2
    Valued Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2007
    Posts
    212

    Re: Query to Show 0 if no match found

    That depends on the version of SQL you are using, for example Access uses NZ(field, value if null). MS SQL uses IsNull(field, value if null), and Oracle uses NVL(field, value if null).

  3. #3
    Valued Forum Contributor pr4t3ek's Avatar
    Join Date
    10-14-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007
    Posts
    471

    Re: Query to Show 0 if no match found

    Access it is
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0