Re: [sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread R Smith
On 2018/06/30 3:12 PM, Luuk wrote: Ok ,my highway to hell start here (regargind the use of SQL) In SQLite3 you are allowed to do this: SELECT a,b,c FROM t1 GROUP BY a The values of 'b' and 'c' will be taken from a 'random' row... But if we rewrite this in SQL, i am getting something like

Re: [sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread Luuk
On 30-6-2018 15:45, Luuk wrote: > > In SQLite3 you are allowed to do this: > SELECT a,b,c > FROM t1 > GROUP BY a > > The values of 'b' and 'c' will be taken from a 'random' row... > > But if we rewrite this in SQL, i am getting something like this: > SELECT >a, >(SELECT MIN(b) FROM T1

Re: [sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread Gerry Snyder
If you want the row with the minimum B, and the row with a minimum C, then the union of two queries would seem to be appropriate. Gerry Snyder On Sat, Jun 30, 2018, 6:45 AM Luuk wrote: > > > On 30-6-2018 15:39, Abroży Nieprzełoży wrote: > >> SELECT > >>a, > >>(SELECT MIN(b) FROM T1

Re: [sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread Abroży Nieprzełoży
>>> SELECT >>>a, >>>(SELECT MIN(b) FROM T1 WHERE a=t.a) AS B, >>>(SELECT MIN(c) FROM T1 WHERE a=t.a) AS C >>> FROM t1 t >>> GROUP BY a >> Why not >> select a, min(b) as b, min(c) as c from t1 group by a; >> ? > > It still does not quarantee that the valuse show for b and c are

Re: [sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread Luuk
On 30-6-2018 15:39, Abroży Nieprzełoży wrote: >> SELECT >>a, >>(SELECT MIN(b) FROM T1 WHERE a=t.a) AS B, >>(SELECT MIN(c) FROM T1 WHERE a=t.a) AS C >> FROM t1 t >> GROUP BY a > Why not > select a, min(b) as b, min(c) as c from t1 group by a; > ? It still does not quarantee that

Re: [sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread Abroży Nieprzełoży
> SELECT >a, >(SELECT MIN(b) FROM T1 WHERE a=t.a) AS B, >(SELECT MIN(c) FROM T1 WHERE a=t.a) AS C > FROM t1 t > GROUP BY a Why not select a, min(b) as b, min(c) as c from t1 group by a; ? 2018-06-30 15:12 GMT+02:00, Luuk : > > On 30-6-2018 14:55, Keith Medcalf wrote: >> Note

[sqlite] GROUP BY [Re: unique values from a subset of data based on two fields]

2018-06-30 Thread Luuk
On 30-6-2018 14:55, Keith Medcalf wrote: > Note that this is SQLite3 specific (and specific to Sybase of the era where > Microsoft SQL Server was actually just a rebranded Sybase, and Microsoft > re-writes of SQL Server up to about 2000). Technically you cannot do a query > of the form: > >