Subject | Re: [firebird-support] Getting distinct rows from a JOIN |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2005-03-30T05:57:32Z |
On 29 Mar 2005 at 17:11, salisburyproject wrote:
criteria.
use this:
SELECT T1.VALUE, T1.ID, min(T2.VALUE) FROM T1 JOIN T2 ON
(T1.ID=T2.ID)
GROUP BY T1.ID, T1.VALUE
--
SY, Dimitry Sibiryakov.
>I want to be able to get the following result from the select:There is no 'first' record in SQL terms unless you specify oreder
>1, V1, V1
>2, V2, V4
>, e.g. get only the first found raw from the joined table.
criteria.
>SELECT T1.VALUE, T1.ID, T2.VALUE FROM T1 JOIN T2 ON (T1.ID=T2.ID)If you indeed don't care what value is returned from right table,
>ORDER BY T1.ID
use this:
SELECT T1.VALUE, T1.ID, min(T2.VALUE) FROM T1 JOIN T2 ON
(T1.ID=T2.ID)
GROUP BY T1.ID, T1.VALUE
--
SY, Dimitry Sibiryakov.