Re: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-14 Thread Igor Tandetnik
On 10/14/2014 3:51 AM, Mark Lawrence wrote: On Tue Oct 14, 2014 at 09:25:20AM +0200, RSmith wrote: To get even more compact, I would go with Igor's SQL which ... will run quite a bit slower I'm a little curious about why you say a CTE statement is slower than a VIEW for large tables. My

Re: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-14 Thread Mark Lawrence
On Tue Oct 14, 2014 at 09:25:20AM +0200, RSmith wrote: > > > >To get even more compact, I would go with Igor's SQL which is > >quite succint, but if those tables are big, that query will run > >quite a bit slower - which is only a problem if the speed really > >matters. I'm a little curious about

Re: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-14 Thread RSmith
And of course there must be a LIMIT 10 added to every Union'd select (which I forgot): SELECT * FROM ReportJobLengths R WHERE GroupName like 'GRP01%' LIMIT 10 UNION ALL SELECT * FROM ReportJobLengths R WHERE GroupName like 'GRP04%' LIMIT 10 UNION ALL SELECT * FROM

Re: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-14 Thread RSmith
On 2014/10/13 23:21, pihu...@free.fr wrote: Hello! I'm trying to find a way to reduce the length of the following query using SQLite: select * from (select GroupName, JobName, Start, End, Status, (strftime('%s', End) - strftime('%s', Start)) as Length from ReportJobs where PlanDate =

Re: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-14 Thread Tony Papadimitriou
To: sqlite-users@sqlite.org Subject: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length Hello! I'm trying to find a way to reduce the length of the following query using SQLite: select * from (select GroupName, JobName, Start, End, Status, (strftime('%s', End) - strftime('%s', Start

Re: [sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-13 Thread Igor Tandetnik
On 10/13/2014 5:21 PM, pihu...@free.fr wrote: Do you know a simplest/better way to perform this query? Something along these lines: select * from ReportJobs r1 where rowid in ( select r2.rowid from ReportJobs r2 where substr(r2.GroupName, 1, 5) = substr(r1.GroupName, 1, 5) and

[sqlite] [SQL Query] Top 10 of 5 different groups sorted by length

2014-10-13 Thread pihug12
Hello! I'm trying to find a way to reduce the length of the following query using SQLite: select * from (select GroupName, JobName, Start, End, Status, (strftime('%s', End) - strftime('%s', Start)) as Length from ReportJobs where PlanDate = '2014-02-13' and GroupName like 'GRP01%' ORDER BY