Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2010
    Posts
    33

    Unanswered: Data extraction issue?

    I can't figure out how to extract data from the table below with an SQL statement with multiple conditions. Take for example the below table

    Bob $120
    Bob $30
    Sam $0
    Sam $20
    Ricahrd
    Ricahrd
    Ricahrd $30

    The above three people Bob, Sam and Ricahrd have different dollar amounts by their names which this table is generated already by a query. Ricahrd has two entries with no dollar amount by his name.. I need to write something that just returns Bob and Sam and not Richard since his name does not have a dollar amount by each entry.

  2. #2
    Join Date
    Aug 2009
    Posts
    262
    if it is a null value u can do some thing like

    select Name from table a
    where Amount is not null

  3. #3
    Join Date
    Jun 2010
    Posts
    33
    They will have a null value, but that would return

    Ricahrd $30

    along with the others. I don't want Ricahrd $30 returned if any other of his values has a null.

  4. #4
    Join Date
    Mar 2009
    Location
    Australia
    Posts
    113
    Code:
    Select Name, Amount
    From Table 
    Where Name Not In (Select Name From Table Where Amount Is Null)

  5. #5
    Join Date
    Jun 2010
    Posts
    33

    Thumbs up Solved

    EngadaSQL thankyou for your reply. You suggestions solved my problem. Now I am just trying to rap my brain around what is actually happening with that sql query / sub query idea.

Posting Permissions

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