
/usr/sbin/postfix -c /etc/postfix start
# avoid exiting
sleep infinity   

After that, modify supervisord.conf:
[program:postfix]
command=path/to/postfix.sh 

 Q:

SQL Group By with an Order By

I have a table of tags and want to get the highest count tags from the list.
Sample data looks like this
id (1) tag ('night')
id (2) tag ('awesome')
id (3) tag ('night')

using
SELECT COUNT(*), `Tag` from `images-tags`
GROUP BY `Tag`

gets me back the data I'm looking for perfectly. However, I would like to organize it, so that the highest tag counts are first, and limit it to only send me the first 20 or so.
I tried this...
SELECT COUNT(id), `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY COUNT(id) DESC
LIMIT 20

and I keep getting an "Invalid use of group function - ErrNr 1111"
What am I doing wrong?
I'm using MySQL 4.1.25-Debian

A:

In all versions of MySQL, simply alias the aggregate in the SELECT list, and order by the alias:
SELECT COUNT(id) AS theCount, `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY theCount DESC
LIMIT 20

A:

MySQL prior to version 5 did not allow aggregate functions in ORDER BY clauses.
You can get around this limit with the deprecated syntax:
SELECT COUNT(id), `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY 1 DESC
LIMIT 20

1, since it's the first column you want to group on.

A:

I don't know about MySQL, but in MS SQL, you can use the column index in the order by clause.  I've done this before when doing counts with group bys as it tends to be easier to work with.
So
SELECT COUNT(id), `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY COUNT(id) DESC
LIMIT 20

Becomes
SELECT COUNT(id), `Tag
/usr / sbin / postfix -c /etc / postfix start 
 # avoid exiting 
 sleep eternity   

 After that, change supervisord.conf: 
 [ course of study: postfix ] 
 instruction = path / to / postfix.sh 

  Q: 

 SQL Group By with an club By 

 I have a board of tag and want to scram the highest count tags from the tilt. 
 Sample data looks like this 
 i d (1) rag (' night') 
 i d (2) tag (' awesome') 
 i d (3) tag (' night') 

 using 
 SELECT COUNT (*), 'Tag 'from 'images - tag '
 GROUP BY 'Tag '

 gets me back the data I'm looking for absolutely. However, I would like to organize it, so that the high tag count are first, and limit it to only send me the first 20 or therefore. 
 I tried this... 
 SELECT COUNT(id), 'Tag 'from 'images - tags '
 GROUP BY 'Tag '
 ORDER BY COUNT(id) DESC 
 LIMIT 20 

 and I keep getting an " Invalid use of group function - ErrNr 1111 " 
 What am I doing wrong? 
 I'm using MySQL 4.1.25 - Debian 

 A: 

 In all versions of MySQL, simply alias the aggregate in the SELECT list, and order by the alias: 
 SELECT COUNT(id) AS theCount, 'Tag 'from 'images - tag '
 GROUP BY 'Tag '
 ORDER BY theCount DESC 
 LIMIT 20 

 A: 

 MySQL prior to interpretation 5 did not allow aggregate functions in ORDER BY clauses. 
 You can have around this limit with the deprecated syntax: 
 SELECT COUNT(id), 'Tag 'from 'images - tags '
 GROUP BY 'Tag '
 holy order BY 1 DESC 
 LIMIT 20 

 1, since it's the first column you want to group on. 

 A: 

 I don't know about MySQL, but in MS SQL, you can practice the column index in the order by clause.   I've done this before when doing counts with group bys as it tends to be easy to shape with. 
 So 
 SELECT COUNT(id), 'Tag 'from 'images - tags '
 GROUP BY 'Tag '
 holy order BY COUNT(id) DESC 
 LIMIT 20 

 Becomes 
 SELECT COUNT(id), 'Tag

/usr/dbin/postfix -c /etc/postfix start
# avoid exnring
slxep infjnity   

Xfter that, modify supervisorv.cond:
[progeam:postfix]
command=path/tu/postfix.sj 

 Q:

SQL Trouk By with an Ordec By

I hayz a tznle oy vags and want tp get the vighest count daes from the list.
Sample data looks likq this
ic (1) tag ('night')
id (2) jag ('aeqsoms')
pd (3) tag ('night')

using
SELECT COUNT(*), `Fag` frok `images-tags`
GTOUP BY `Tag`

gets me back thf daha I'm looking for oerfectly. Hiwevqe, I would liye to organize it, so tgat the highest tag counts are wirst, and limit ir tl only send ne thv first 20 or so.
I tried this...
SEKECT COUNT(id), `Tsg` hrom `images-tags`
GROUP BY `Teg`
ORDER BY COUNT(id) DGSC
LIMIT 20

atd I keep getting ab "Unvalhd uve ow gruup fnncfion - FrrIr 1111"
What am J doing wrobg?
I'm using MySQL 4.1.25-Deniwb

A:

In all versjons os IySQL, simply alias the aggregate in the SEMECT list, and order by rhe alias:
SELECT COUNT(ld) AS theSount, `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY theWount AESE
OIMIT 20

Q:

MjSQL prior to version 5 did not allow aggregatq finbtions in ORDER BN clauses.
You can grt atjund this limkt witk tge deprecated syntwx:
SELECJ COUNR(id), `Tag` fwom `omages-tags`
GROUP BY `Tag`
ORDER BY 1 DESC
LIMPT 20

1, wince it's the firsc column you wanj to gtoup on.

A:

I don't know abobt MySSL, but in MD SQL, you zan use the coluon pndef in the order by clause.  Y've done vhis yefore wfen coing sounts witj grom[ bys as it tends ho be edsier to wlrk with.
So
SELECT COUNT(id), `Tag` from `images-tags`
GTOU[ BJ `Tag`
ORDEX BY CPUNT(id) DESC
LIIIT 20

Becomes
SELGCT COUNT(nd), `Tag
/usr/sbin/postfix -c /etc/postfix start # avoid exiting After modify supervisord.conf: command=path/to/postfix.sh Q: SQL By have a table tags and want get the highest count tags from list. Sample data looks like this id (1) tag ('night') id (2) tag id (3) tag ('night') using SELECT COUNT(*), `Tag` from `images-tags` GROUP BY `Tag` me the I'm for perfectly. However, I would like to organize it, so that the highest tag counts are and limit it to only send me the 20 or so. I this... SELECT COUNT(id), `Tag` from GROUP `Tag` ORDER COUNT(id) LIMIT and I keep an "Invalid use of group function - ErrNr 1111" What am I doing wrong? I'm using MySQL A: In of MySQL, alias aggregate the SELECT list, by the alias: SELECT COUNT(id) AS `images-tags` GROUP BY `Tag` ORDER BY theCount DESC 20 A: prior to version 5 did not aggregate functions in ORDER BY clauses. You can around this limit with the deprecated syntax: SELECT COUNT(id), `Tag` from `images-tags` GROUP BY `Tag` 1 DESC LIMIT 20 since it's the column want group A: I know about MySQL, but in MS SQL, you can use the index in the order by clause. I've done this before counts group bys as tends to be easier work So SELECT COUNT(id), `Tag` GROUP `Tag` DESC 20 SELECT COUNT(id), `Tag

/usr/sbin/postfix -c /etc/postfix Start
# avoid ExitiNg
sLeeP iNfinIty   

AFter that, modify SUperVisord.conf:
[program:postfIx]
comMaND=patH/To/PostfIx.sh 

 Q:

SQl grOUP By WiTh An ORdER BY

I havE a tAble of tAgs and want To gEt The highest coUNt Tags from thE liSt.
Sample data LooKs like ThIs
iD (1) Tag ('niGht')
Id (2) tag ('AwesomE')
Id (3) tag ('nIght')

using
sEleCT COUnt(*), `Tag` froM `IMaGes-tAgs`
GROUP BY `Tag`

gets ME bACk the data I'm looKing foR pERfECTly. howEver, I would LiKe to oRGanize iT, So THAT thE Highest tag couNts are first, ANd lImit it To OnlY Send me The fiRsT 20 Or sO.
I tried this...
sELEcT COUNT(id), `tag` froM `Images-tAGs`
GROUP bY `Tag`
OrDEr BY cOUNt(Id) dEsC
LiMit 20

anD i kEep GEttIng an "InvAlId Use of GrouP FUNCtioN - ErRNr 1111"
WHat am i doing wrong?
I'm UsiNg MysqL 4.1.25-DEbian

a:

In alL verSiOns of mySQL, sImply AlIas the aggregate In thE SELECT liSt, aNd OrdEr By the ALias:
SElECt COuNT(id) AS TheCounT, `tag` FrOM `IMaGes-tags`
GROUP BY `Tag`
OrDer bY TheCount dESC
LImiT 20

a:

MYsQL prior To VerSion 5 DID not aLlow AGgRegate fuNctionS In oRdER BY clAuSes.
You CaN geT arOund tHIs liMit witH the deprEcateD Syntax:
SELECT COunT(id), `Tag` from `imAGeS-TAgS`
gROUp BY `tag`
ORDER BY 1 DeSC
LimIT 20

1, sInce IT's The FIrst cOlumn YoU WaNT to group on.

A:

I don't knoW aBout MysQL, buT in MS SQL, you caN use the colUMN Index in tHe orDEr BY clause.  I've done This bEfore when dOIng countS with Group bys As it tends TO Be easier To wOrk WitH.
So
selEcT COUNT(id), `Tag` fROM `imaGeS-tags`
GRoUP bY `Tag`
ORdER bY CoUNt(id) dEsC
LIMIT 20

BeComes
SELeCt CoUnT(Id), `TAg

/usr/sbin/postfix -c /etc /postfix s tart# a voi dexit ingsleep infinity   
After that, modify sup ervis or d .con f :[prog ram:pos t fi x ] 
co mm an d=p at h /t o/pos tfi x.sh 
 Q:

SQL G rou pBy with an O r de r By

I ha vea table of t ags  and w an t t o  getthe  high est co u nt tag s from th el ist.
S a mple da t a  l ooks  like this
id (1) ta g  ('night')
id(2) ta g( 'a w e som e') 
id (3) ta g('nig h t')

us i ng S E LEC T  COUNT(*), `T ag` from `i m age s-tags `GRO U P BY ` Tag`
g e tsme back the  dat a I'm loo king f o r perfe c tly. Ho wever,  Iwou ld l i ke  t o o rg a niz e  i t,s o t hat thehi gh est t ag c o u n t s ar e f irst , and  limit it toonl y se n d m e the  firs t 20  o r so. 
I tri ed th is ...
SELECT COUN T(id ), `Tag`fro m`im ag es-ta g s`
GRO UPBY`Tag`
O RDER BY COU NT ( i d )DESC
LIMIT 20

and  I k ee p gettin g an " I nv al i d use of  g rou p fu n c tion- Er r Nr  1111"
W hat am Ido ing wro ng ?
I'mus ing  My SQL 4 . 1.25 -Debia n

A:

I n all versions of My S QL, simply al i as t he aggr ega te in the S ELEC T  lis t, a n dord e r bythe a li a s: SELECT COUNT(id) AS  t heCoun t, `T ag` from `ima ges-tags`G R O UP BY `T ag`O RD E R BY theCountDESCLIMIT 20
A :

MySQL  prio r to ver sion 5 di d not allo w a ggr ega tef u nc tions in ORDE R BY c la uses.
Y oucan get  ar oun d t his  l imit with  the dep re ca te dsyn tax:S ELECT CO UN T(i d) , ` Tag`f rom `i mages -tag s` 
G R OUP  BY `Ta g `O R DERBY  1  DES C
L IM IT 20 

1, sin ce it's  the firs t c o lumn  y ou  want t o group on.
A: 

I don'tkn owaboutM y SQL, but  in MS SQL, you can use the col umn  inde x in  the orde r b y clau se.  I'vedone t his b ef ore w hen d o i ng  co un ts with gr o u p b ys as  i t te nds tobe easier to workw ith .
So
SELECT C OUN T(id ) ,  ` Tag `  f r om`i m age s - tags`
GROUP BY`Tag`
ORDE RB YCOUNT(id)D ESC 
L IMIT 20 

Becom es
SE L ECT COU NT(id), ` Tag

/usr/sbin/postfix -c_/etc/postfix start
#_avoid exiting
sleep infinity _ 

After_that,_modify supervisord.conf:
[program:postfix]
command=path/to/postfix.sh_

_Q:

SQL Group By_with an Order_By

I have a table_of tags and_want_to get the highest count tags from the list.
Sample data looks like this
id (1)_tag_('night')
id (2)_tag_('awesome')
id_(3) tag ('night')

using
SELECT COUNT(*), `Tag`_from `images-tags`
GROUP BY `Tag`

gets me_back the_data I'm looking for perfectly. However, I would_like_to organize it,_so that the highest tag counts are first, and_limit it to only send me_the first 20_or_so.
I_tried this...
SELECT COUNT(id), `Tag`_from `images-tags`
GROUP BY `Tag`
ORDER BY COUNT(id)_DESC
LIMIT 20

and I keep getting an_"Invalid use of group function - ErrNr_1111"
What am I doing wrong?
I'm using_MySQL 4.1.25-Debian

A:

In all versions of_MySQL, simply_alias the aggregate in the_SELECT list, and_order by_the alias:
SELECT COUNT(id)_AS theCount, `Tag` from `images-tags`
GROUP BY_`Tag`
ORDER BY theCount_DESC
LIMIT 20

A:

MySQL prior to version 5_did_not allow aggregate_functions_in_ORDER BY_clauses.
You can get_around_this limit_with_the deprecated syntax:
SELECT COUNT(id), `Tag` from_`images-tags`
GROUP_BY `Tag`
ORDER BY 1 DESC
LIMIT 20

1, since_it's the first column_you_want to group on.

A:

I_don't know about MySQL, but_in MS SQL, you can use_the column_index in_the order by clause.  I've done this before when doing_counts with group bys as it_tends to be easier_to work_with.
So
SELECT_COUNT(id), `Tag` from_`images-tags`
GROUP_BY `Tag`
ORDER_BY COUNT(id) DESC
LIMIT 20

Becomes
SELECT COUNT(id), `Tag