By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,611 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,611 IT Pros & Developers. It's quick & easy.

Removing a record from resultset using SQL

P: 48
Hi,

I am writing a SQL code in DB2 for a report. My problem is something like this :
there and event_id in a table.. that is having values in order 1,2,3,4,5 .. and so on .. if there is any event ids for a customer are 1 and 81 , I will have to show only 81th record and for 1, 91 .. I will have to show only 91th record and so on .. and if a particular customer is not having any even id in 8X or 9X series then I will have to show exact data ..

Here is an example :

Cust 1
event_id--City---State--- zip
1 -- abc --- def -- 22804
2 --------- xyz --- xab -- 22564
81 --------- abc -- hsh-- 22222

The expected output should be :
event_id--City---State--- zip
2 --------- xyz --- xab -- 22564
81 --------- abc -- hsh-- 22222


Cust 2
1 -- abc --- def -- 22804
2 --------- xyz --- xab -- 22564

The expected output should be :
event_id--City---State--- zip
1 -- abc --- def -- 22804
2 --------- xyz --- xab -- 22564


Please help me out in this how can I handle this using SQL.
Jun 20 '07 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
Hi,

I am writing a SQL code in DB2 for a report. My problem is something like this :
there and event_id in a table.. that is having values in order 1,2,3,4,5 .. and so on .. if there is any event ids for a customer are 1 and 81 , I will have to show only 81th record and for 1, 91 .. I will have to show only 91th record and so on .. and if a particular customer is not having any even id in 8X or 9X series then I will have to show exact data ..

Here is an example :

Cust 1
event_id--City---State--- zip
1 -- abc --- def -- 22804
2 --------- xyz --- xab -- 22564
81 --------- abc -- hsh-- 22222

The expected output should be :
event_id--City---State--- zip
2 --------- xyz --- xab -- 22564
81 --------- abc -- hsh-- 22222


Cust 2
1 -- abc --- def -- 22804
2 --------- xyz --- xab -- 22564

The expected output should be :
event_id--City---State--- zip
1 -- abc --- def -- 22804
2 --------- xyz --- xab -- 22564


Please help me out in this how can I handle this using SQL.
Please don't double post .
Jun 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.