If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Find the first occurance of zero

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-04, 15:04
oracle08821 oracle08821 is offline
Registered User
 
Join Date: Feb 2004
Posts: 24
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
Reply With Quote
  #2 (permalink)  
Old 07-14-04, 15:11
J Petruk J Petruk is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 07-14-04, 15:45
oracle08821 oracle08821 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 07-14-04, 19:08
J Petruk J Petruk is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On