[web2py] Re: Select Distinct for more than 1 distinct value

2012-07-26 Thread Derek
Usually, when you are asking these kind of questions, you come to realize you are asking the wrong question. On Monday, July 23, 2012 3:15:14 PM UTC-7, Mark Li wrote: > > I have a database setup with id and 'dogname.' I would like to retrieve > distinct values of dogname, but allow for 2 of each

[web2py] Re: Select Distinct for more than 1 distinct value

2012-07-25 Thread villas
I have only seen complex queries to solve this. The sql can differ according to the DB. Example for SQL Server: http://archive.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=SelectTopNByGroup Sometimes grabbing more data than you need and then discarding it is quicker and easier than

[web2py] Re: Select Distinct for more than 1 distinct value

2012-07-23 Thread Mark Li
I'll be looping over them for now, is there anyway to use a query or select() to return a set with no more than 2 of each name? On Monday, July 23, 2012 3:43:38 PM UTC-7, villas wrote: > > I can't see how distinct would help there because it only returns unique > rows. > > I would say that the m

[web2py] Re: Select Distinct for more than 1 distinct value

2012-07-23 Thread villas
I can't see how distinct would help there because it only returns unique rows. I would say that the main question is how much data you have. I mean, it is probably easier to grab all the data and then discard (or simply loop over) the data you do not need. However, if you have a huge number