Re: how to create query ??????????
Date: Fri, 16 Jan 2004 12:20:58 +0100
Message-ID: <1074250900.729363_at_news.thyssen.com>
"KULJEET" <kuljeet_twtpl_at_hotmail.com> wrote...
> i have a table with following data
> qty start_no end_no
> 1 1 100
> 1 101 200
> 1 201 300
> 1 5001 5100
> 1 7001 7100
> 1 7101 7200
>
> i used query like
> select sum(qty),min(start_no),max(end_no) from <table_name>;
>
> it show
> 6 1 7200
>
> BUT I WANT
> 3 1 300
> 1 5001 5100
> 2 7001 7200
>
> PLZ HELP ME????????????????
>
> THANKS A LOT
> kuljeet pal singh
Eat this:
select sum(qty),min(start_no),max(end_no)
from <table_name>
where end_no < 301
union all
select sum(qty),min(start_no),max(end_no)
from <table_name>
where start_no >= 5001 and end_no <= 7000
union all
select sum(qty),min(start_no),max(end_no)
from <table_name>
where start_no >= 7001 and end_no <= 7200;
If that doesn't fit your needs, start thinking. Received on Fri Jan 16 2004 - 12:20:58 CET