[thelist] SQL... group by prob...

Barry Woolgar barry at burnthebook.co.uk
Tue Sep 18 09:02:09 CDT 2007


Hello

Apologies for the previous, it was sent before I received your first reply
:)

Could it be doing the ordering before the grouping? Not sure how you go
about forcing the issue, or ordering the results of the grouping as a
separate action (in the same statement).

Barry



-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tris
Sent: 18 September 2007 14:48
To: thelist at lists.evolt.org
Subject: Re: [thelist] SQL... group by prob...

Yes.. in my query I AM using backticks...
I jsut didn't write them down in this mail, to save time...

for the record, my query is this:

SELECT * FROM `orders` WHERE `percent` > 0 GROUP BY `offer_id` ORDER BY
`date` DESC

though if there's 100 entries of offer_id 12 (eg) and date ranges over
several months, we always just get the last date in the DB... but we need to
sort by that date too...





On 18/09/2007, Barry Woolgar <barry at burnthebook.co.uk> wrote:
> Hello again,
>
> To clarify, the reason it _needs_ to be in backticks/quotes is because 
> DATE is a mysql function so its possible you're causing syntax errors. 
> Of course mysql doesn't stop you creating fields that have the same 
> name as functions so it's a good idea not to use field names like 
> 'order' or 'date' just in case you forget about the quotes in the
statement.
>
> Barry
>
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Barry Woolgar
> Sent: 18 September 2007 14:29
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] SQL... group by prob...
>
> Ello...
>
> > Am I being a tool...?
> > GROUP BY offer_id ORDER BY date DESC doesn't work...
>
> Are you getting a specific SQL error? I'm pretty sure you need to put
'date'
> in backticks for it to be valid, ie:
>
> ... GROUP BY `offer_id` ORDER BY `date` DESC
>
> Barry
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.22/1013 - Release Date: 
> 17/09/2007
> 13:29
>
>
> --
>
> * * Please support the community that supports you.  * * 
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester and 
> archives of thelist go to: http://lists.evolt.org Workers of the Web,
evolt !
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.22/1013 - Release Date: 
> 17/09/2007
> 13:29
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.487 / Virus Database: 269.13.22/1013 - Release Date: 
> 17/09/2007
> 13:29
>
>
> --
>
> * * Please support the community that supports you.  * * 
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester and 
> archives of thelist go to: http://lists.evolt.org Workers of the Web, 
> evolt !


--
Give a man a fish and he'll feed himself for a day.
Give a man a religion and he'll starve to death praying for a fish.
Anon

`We are what we pretend to be, so we must be careful what we pretend to be.`
Kurt Vonnegut

`When a person can no longer laugh at himself, it is time for others to
laugh at him.` Thomas Szasz
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 


No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.487 / Virus Database: 269.13.22/1013 - Release Date: 17/09/2007
13:29
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.487 / Virus Database: 269.13.22/1013 - Release Date: 17/09/2007
13:29
 




More information about the thelist mailing list