Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    24

    Unanswered: Find the first occurance of zero

    Hi,

    prod ac rate fundg fee pch_upb upb eff_qtr
    upb_qtr

    OTHER, AFS, 0.0875, 2002Q2, 39960.39, 1656279.17, 1151445.52,2002Q4, 2002Q2

    OTHER, AFS, 0.0875, 2002Q2, 39960.39, 1656279.17, 0, 2002Q4, 2002Q3

    OTHER, AFS, 0.0875, 2002Q2, 39960.39, 1656279.17, 0, 2002Q4, 2002Q4

    I have a table test
    which has 9 columns prod, ac, rate, fund etc
    and has some records and at some point upb goes to zero(0) and I want to select the first occruance of zero.

    If any one can let me know how to do this in DB2, that will be a great help.

    Thanks in advance

    Srinivas
    Thanks
    Srinivas chityala

  2. #2
    Join Date
    Mar 2004
    Location
    Toronto, ON, Canada
    Posts
    513
    Quote Originally Posted by oracle08821
    Hi,

    prod ac rate fundg fee pch_upb upb eff_qtr
    upb_qtr

    OTHER, AFS, 0.0875, 2002Q2, 39960.39, 1656279.17, 1151445.52,2002Q4, 2002Q2

    OTHER, AFS, 0.0875, 2002Q2, 39960.39, 1656279.17, 0, 2002Q4, 2002Q3

    OTHER, AFS, 0.0875, 2002Q2, 39960.39, 1656279.17, 0, 2002Q4, 2002Q4

    I have a table test
    which has 9 columns prod, ac, rate, fund etc
    and has some records and at some point upb goes to zero(0) and I want to select the first occruance of zero.

    If any one can let me know how to do this in DB2, that will be a great help.

    Thanks in advance

    Srinivas
    SELECT... WHERE UPB=0... ORDER BY... FETCH FIRST ROW ONLY;
    --
    Jonathan Petruk
    DB2 Database Consultant

  3. #3
    Join Date
    Feb 2004
    Posts
    24
    Quote Originally Posted by J Petruk
    SELECT... WHERE UPB=0... ORDER BY... FETCH FIRST ROW ONLY;
    I want to get the all non zero upbs and first occurance of zero, table has more that 100 records.

    Thanks
    Srinivas
    Thanks
    Srinivas chityala

  4. #4
    Join Date
    Mar 2004
    Location
    Toronto, ON, Canada
    Posts
    513
    Quote Originally Posted by oracle08821
    I want to get the all non zero upbs and first occurance of zero, table has more that 100 records.

    Thanks
    Srinivas
    SELECT ... FROM ... WHERE upbs != 0
    UNION
    (SELECT ... FROM ... WHERE upbs = 0 ORDER BY <ORDER> fetch first row only);
    --
    Jonathan Petruk
    DB2 Database Consultant

Posting Permissions

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