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

Need help in get the result in the format

P: 2
In the table


sERIES TICKETNO STATUS

THE MIN DIFFERENCE WILL BE BETWEEN 1 ST ROW AND NEXT ROW WILL BE 10000


1 100000 0
1 100000 1
1 120000 0
1 130000 0
1 140000 0
1 150000 1
1 160000 0
1 170000 1
1 180000 0
1 190000 1
1 200000 0

CONTIUNED DEPENDS ON HOW MANY TICKETS ARE ALLOTED




2 100000 0
2 110000 0
2 120000 1
2 130000 1
2 140000 0
2 150000 1
2 160000 1
2 170000 0
2 180000 0
2 190000 1
2 200000 0

CONTIUNED DEPENDS ON HOW MANY TICKETS ARE ALLOTED

3 100000 0
3 110000 0
3 120000 0
3 130000 0
3 140000 0
3 150000 1
3 160000 1
3 170000 0
3 180000 0
3 190000 1
3 200000 0

CONTIUNED DEPENDS ON HOW MANY TICKETS ARE ALLOTED



FROM THIS TABLE QUERY IS




SELECT TOP N TICKETNO FROM TABLE WHERE STATUS=0


TOP N MAY CHANGE, SAY NOW 20

SELECT TOP 20 TICKETNO FROM TABLE WHERE STATUS=0


NOW THE RESUTL SET WILL BE


1 100000 0
1 120000 0
1 130000 0
1 140000 0
1 160000 0
1 180000 0
1 200000 0

2 100000 0
2 110000 0
2 140000 0
2 170000 0
2 180000 0
2 200000 0

3 100000 0
3 110000 0
3 120000 0
3 130000 0
3 140000 0
3 170000 0
3 180000 0



BUT I NEED THE RESULT SET AS

GROUP BY SERIES TICKETNO

11000 IS NOT AVAILABLE
SO

1 100000-100000
1 120000-140000

NOW 150000 IS NOT AVAILABLE

SO

1 160000-160000

BECAUSE 170000 IS NOT AVAILABLE

1 180000-180000

1 200000-200000



NOW THE SERIES CHANGES TO 2

2 100000-110000
2 140000-140000
2 170000-180000
Apr 11 '08 #1
Share this Question
Share on Google+
2 Replies


P: 44
In the table


sERIES TICKETNO STATUS

THE MIN DIFFERENCE WILL BE BETWEEN 1 ST ROW AND NEXT ROW WILL BE 10000


1 100000 0
1 100000 1
1 120000 0
1 130000 0
1 140000 0
1 150000 1
1 160000 0
1 170000 1
1 180000 0
1 190000 1
1 200000 0

CONTIUNED DEPENDS ON HOW MANY TICKETS ARE ALLOTED




2 100000 0
2 110000 0
2 120000 1
2 130000 1
2 140000 0
2 150000 1
2 160000 1
2 170000 0
2 180000 0
2 190000 1
2 200000 0

CONTIUNED DEPENDS ON HOW MANY TICKETS ARE ALLOTED

3 100000 0
3 110000 0
3 120000 0
3 130000 0
3 140000 0
3 150000 1
3 160000 1
3 170000 0
3 180000 0
3 190000 1
3 200000 0

CONTIUNED DEPENDS ON HOW MANY TICKETS ARE ALLOTED



FROM THIS TABLE QUERY IS




SELECT TOP N TICKETNO FROM TABLE WHERE STATUS=0


TOP N MAY CHANGE, SAY NOW 20

SELECT TOP 20 TICKETNO FROM TABLE WHERE STATUS=0


NOW THE RESUTL SET WILL BE


1 100000 0
1 120000 0
1 130000 0
1 140000 0
1 160000 0
1 180000 0
1 200000 0

2 100000 0
2 110000 0
2 140000 0
2 170000 0
2 180000 0
2 200000 0

3 100000 0
3 110000 0
3 120000 0
3 130000 0
3 140000 0
3 170000 0
3 180000 0



BUT I NEED THE RESULT SET AS

GROUP BY SERIES TICKETNO

11000 IS NOT AVAILABLE
SO

1 100000-100000
1 120000-140000

NOW 150000 IS NOT AVAILABLE

SO

1 160000-160000

BECAUSE 170000 IS NOT AVAILABLE

1 180000-180000

1 200000-200000



NOW THE SERIES CHANGES TO 2

2 100000-110000
2 140000-140000
2 170000-180000

sorry to say that question is not clear . Please be more precise in the requirement.
Apr 15 '08 #2

ck9663
Expert 2.5K+
P: 2,878
As I recommended, you might need to resort to CURSOR

-- CK
Apr 15 '08 #3

Post your reply

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