Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Posts
    87

    Unanswered: problem with results

    Hi everybody

    Have this problem to solve with this table I need to display a record twice on the query result if DATED and SIGNED are not nulls...

    (REGISTER)
    filenumber dated signed

    1 2009-09-01 AA
    2 2009-09-02

    SELECT * from REGISTER
    WHERE dated is not NULL
    (result is 2 records)

    SELECT * from REGISTER
    WHERE SIGNED is not null
    (result 1 record)

    the result I need is 3 records wherein filenumber 1 should be displayed twice
    filenumber dated signed

    1 2009-09-01 AA
    1 2009-09-01 AA
    2 2009-09-02


    thanks all

  2. #2
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    alexiop, Try this:
    Code:
    SELECT filenumber, dated, signed
    FROM REGISTER
    WHERE dated IS NOT NULL
      UNION ALL
    SELECT filenumber dated signed
    FROM REGISTER
    WHERE signed IS NOT NULL
    ORDER BY filenumber, dated, signed
    UNION ALL will combine the two result sets and leave duplicates.

  3. #3
    Join Date
    Aug 2006
    Posts
    87
    THANKS!!! THAT DID THE TRICK


    Quote Originally Posted by Stealth_DBA
    alexiop, Try this:
    Code:
    SELECT filenumber, dated, signed
    FROM REGISTER
    WHERE dated IS NOT NULL
      UNION ALL
    SELECT filenumber dated signed
    FROM REGISTER
    WHERE signed IS NOT NULL
    ORDER BY filenumber, dated, signed
    UNION ALL will combine the two result sets and leave duplicates.

Posting Permissions

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