You use total for the group by by not for having. Dan
From: Bruce Chitiea Sent: Monday, April 16, 2012 8:50 AM To: RBASE-L Mailing List Subject: [RBASE-L] - Re: Order By, Fail Steve & Dan: Excellent. Both approaches work. Pushed a little further and found that using the alias within the HAVING statement: 'HAVING total > n' ... breaks, as the alias 'total' is regarded as an unknown column. Learned much. Many thanks. Bruce -------- Original Message -------- Subject: [RBASE-L] - Re: Order By, Fail From: "Dan Goldberg" <[email protected]> Date: Mon, April 16, 2012 8:38 am To: [email protected] (RBASE-L Mailing List) Try alias the count: SELECT columnname,count(columnname) as `Total` + FROM tablename + WHERE othercolumn=something + GROUP BY columnname + HAVING count(columnname) > n + ORDER BY Total,columnname Dan Goldberg From: Bruce Chitiea Sent: Monday, April 16, 2012 8:13 AM To: RBASE-L Mailing List Subject: [RBASE-L] - Order By, Fail All: Display: Courier New RBX_91(64) 9.1.5.20410 In the following code, everything works but the ORDER BY clause, which returns the error: '-ERROR-Bad ORDER BY clause (2363)' SELECT columnname,count(columnname) + FROM tablename + WHERE othercolumn=something + GROUP BY columnname + HAVING count(columnname) > n + ORDER BY count(columnname),columnname ?? Bruce

