Re: AVG Function

2004-08-27 Thread Michael Stassen
Craig Hoffman wrote: Mark, Yes its close and thank you. The problem I am having is I am able to generate the correct ranking.id for that particular user but I can't seem to make it equal the ranking.rating. ID ranking.rating 9 = 5.6 (example) Here's my query: SELECT routes.user_id, ran

Re: AVG Function

2004-08-27 Thread SGreen
Hi Craig, Sorry this is such a slow response but I have been swamped and I didn't see where anyone else has responded yet. First, we need to calculate the average ID per user but round the average to the nearest whole number. CREATE TEMPORARY TABLE tmpResults SELECT cast((AVG(id)+ .5) as inte

Re: AVG Function

2004-08-25 Thread Craig Hoffman
Mark, Yes its close and thank you. The problem I am having is I am able to generate the correct ranking.id for that particular user but I can't seem to make it equal the ranking.rating. ID ranking.rating 9 = 5.6 (example) Here's my query: SELECT routes.user_id, ranking.rating, ROUND(A

AVG Function

2004-08-24 Thread Craig Hoffman
Hey Everyone, I can you some assistance on this query. I have three tables one is called ranking and the other is called routes and finally the users table. The users table is not really important. The ranking table looks like this: id rating 1 5.0 2 5.1 3 5.2 4 5.3

Re: AVG function in order by clause

2004-05-05 Thread Paul DuBois
=GR.DB_ESTABLISHMENT_ID GROUP BY ES.DB_ESTABLISHMENT_ID HAVING AVG(DB_GRADE) > 2 ORDER BY AVG(GRADE) ** Now I am having a problem with the order by clause. How can I have the AVG function in the ORDER BY clause or how can I sort by average grade? As others h

Re: AVG function in order by clause

2004-05-05 Thread Carsten R. Dreesbach
Pretty simple, declare an alias in your query and use it in the ORDER BY, i.e.:   SELECT  DB_ESTABLISHMENT_NAME, AVG(DB_GRADE) AS AVGGRADEFROM  ESTABLISHMENTS ES LEFT OUTER JOIN GRADES GR ONES.DB_ESTABLISHMENT_ID=GR.DB_ESTABLISHMENT_IDGROUP BY  ES.DB_ESTABLISHMENT_IDHAVING  AVG(DB_GRADE) > 2ORDER B

Re: AVG function in order by clause

2004-05-05 Thread Daniel Clark
ISHMENTS ES LEFT OUTER JOIN GRADES GR ON > ES.DB_ESTABLISHMENT_ID=GR.DB_ESTABLISHMENT_ID > > GROUP BY > ES.DB_ESTABLISHMENT_ID > > HAVING > AVG(DB_GRADE) > 2 > > ORDER BY > AVG(GRADE) > ** > > Now I am having a problem wit

Re: AVG function in order by clause

2004-05-05 Thread Josh Trutwin
*** > > Now I am having a problem with the order by clause. How can I have > the AVG function in the ORDER BY clause or how can I sort by average > grade? I THINK you need to alias your column to do this: SELECT DB_ESTABLISHMENT_NAME, AVG(DB_GRADE) AS AVG_GRADE

AVG function in order by clause

2004-05-05 Thread Julien Martin
Thank you all for your replies. Everything works now!! Julien. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

RE: AVG function in order by clause

2004-05-05 Thread Victor Pendleton
What kind of problem are you having? You can use the ordinal postion. ORDER BY 2 [ASC|DESC]. 2 represents the second column. -Original Message- From: Julien Martin To: '[EMAIL PROTECTED]' Sent: 5/5/04 12:41 PM Subject: AVG function in order by clause Hello, Thanks a lot for t

AVG function in order by clause

2004-05-05 Thread Julien Martin
ES.DB_ESTABLISHMENT_ID HAVING AVG(DB_GRADE) > 2 ORDER BY AVG(GRADE) ** Now I am having a problem with the order by clause. How can I have the AVG function in the ORDER BY clause or how can I sort by average grade? Thanks in advance, Julien Mar