# Thread: Find the first occurance of zero

1. Registered User
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.

Srinivas

2. Registered User
Join Date
Mar 2004
Location
Posts
513
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.

Srinivas
SELECT... WHERE UPB=0... ORDER BY... FETCH FIRST ROW ONLY;

3. Registered User
Join Date
Feb 2004
Posts
24
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

4. Registered User
Join Date
Mar 2004
Location
Posts
513
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);

#### Posting Permissions

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