Re: Selecting minimum values of same column in three tables
Date: Fri, 23 May 2003 17:43:50 +0000
Message-ID: <2916601.1053711830_at_dbforums.com>
Originally posted by Erwin
> It is indeed that I did not include the other column: seq 2, but
> how did you
> find out? Just wondering.
>
> This is what I would like to achieve but in each of the select
> statement
> group, it contains group by and order by expression and when I
> tried to
> enclose the first select statement with brackets around it, it gave
> me error
> of not recognizing the identified in the group by statement.
> Anything wrong with the bracketing ?
>
> SELECT id#1, seq, min(id#2)
> FROM
> ( SELECT id#1, seq, id#2 FROM table1 group by id#1, seq
> UNION
> SELECT id#1, seq, id#2 FROM table2 group by id#1, seq
> );
>
>
I didn't know that you actually had another column, just that there
needed to be one.
Try this:
SELECT id#1, seq, min(id#2)
FROM
( SELECT id#1, seq, id#2 FROM table1
UNION
SELECT id#1, seq, id#2 FROM table2
)
group by id#1, seq;
-- Posted via http://dbforums.comReceived on Fri May 23 2003 - 19:43:50 CEST