Hi

Is it possible to apply order by for a union query and how.

eg:

create table one(id int auto_increment, v_date date, name varchar(20),
amount double)

insert into one values(default, '2010-01-04', 'abcd', 400)
insert into one values(default, '2010-01-04', 'efgh', 400)
insert into one values(default, '2010-01-04', 'ijkl', 400)
insert into one values(default, '2010-01-05', 'abcd', 500)
insert into one values(default, '2010-01-05', 'efgh', 500)
insert into one values(default, '2010-01-05', 'ijkl', 500)
insert into one values(default, '2010-01-06', 'abcd', 600)
insert into one values(default, '2010-01-06', 'efgh', 600)
insert into one values(default, '2010-01-06', 'ijkl', 600)

now i run the below queries:
Query 1
======
select id, name sum(amount) from one where v_date between '2010-01-05'
and '2010-01-06' group by id, name order by name
Query 2
======
select id, name sum(amount) from one where v_date < '2010-01-05' group
by id, name order by name

required result
============
the result obtained in query 1 and query 2 should be obtained by
running 1 query some thing like
select id, name sum(amount) from one where v_date between '2010-01-05'
and '2010-01-06' group by id, name order by name union select id, name
sum(amount) from one where v_date < '2010-01-05' group by id,  name
order by name

Thanking you

Regds - K. Prakash

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to