Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    1

    Red face Unanswered: DB2 Union Function

    Hi
    i am using below query

    select Year(current_date) from SYSIBM.SYSDUMMY1
    UNION
    select Month(current_date) from SYSIBM.SYSDUMMY1
    UNION
    select day(current_date) from SYSIBM.SYSDUMMY1


    to select year month and day, this query works fine if the month and day are not same i.e.
    if the date is 2011-09-08 than it returns
    2011
    9
    8

    but if the date is 2011-09-09 it only returns two rows
    2011
    9

    in both the cases if i run queries individually it returns proper values..

    Can you please tell me whats going wrong with this....
    Thanks in advance

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Use "UNION ALL" instead of "UNION".

    UNION removes duplicated rows.

  3. #3
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    teachers will have big opportunities..
    DB2 University
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Tags for this Thread

Posting Permissions

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