Re: Problem with SQL query
| From: | JJ Harrison | Date: | Sun, 07 Jul 2002 11:53:57 +0000 |
| Subject: | Re: Problem with SQL query | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-105954@lists.php.net to get a copy of this message | ||
I have fixed it now don't worry!
--
JJ Harrison
webmaster@tececo.com
www.tececo.com
"Alberto Serra" <albertoserra@gala.net> wrote in message
news:3D28105B.8090309@gala.net...
> ðÒÉ×ÅÔ!
>
> I forgot to add:
>
> SELECT
> extract('year', time),
> extract('month', time),
> count(*) as monthly_views
> FROM
> visitors
> group by
> extract('year', time),
> extract('month', time)
> order by
> monthly_view desc
> limit 1
>
> I take it that you have a *monthly_view* column in your table that is
> not the *monthly_views* alias yoiu use in your query. if that's a typo
> and you mean to order by the numebr of visitors (that is, you want the
> most visited month on top of the result) your query should probably look
> like:
>
> SELECT
> extract('year', time),
> extract('month', time),
> count(*) as monthly_views
> FROM
> visitors
> group by
> extract('year', time),
> extract('month', time)
> order by
> 3 desc
> limit 1
>
> That's because most databases (and I guess MySql is no exception) will
> not be able to use an alias in their GROUP BY, ORDER BY clauses. But you
> may want to try, maybe MySql *is* an exception, after all.
>
> ÐÏËÁ
> áÌØÂÅÒÔÏ
> ëÉÅ×
>
>
> --
>
>
> @-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@
>
> LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
> lOrD i'M sHiNiNg...
> YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
> tHe TeSt, YeS iT iS
> ThE tEsT, yEs It Is
> tHe TeSt, YeS iT iS
> ThE tEsT, yEs It Is.......
>