Forum Moderators: open

Message Too Old, No Replies

Two decimal places syntax

Adding FORMAT(variable,2) not working

         

s9901470

9:33 pm on Dec 7, 2005 (gmt 0)

10+ Year Member



Hi

I'm trying to format this to two decimal places but adding FORMAT(mean,2) doesn't seem to work. Any suggestions?

$queryrating = "SELECT table1.title AS label, SUM(table2.rating) AS total, AVG(table2.rating) AS mean FROM table1, table2 WHERE table1.id = table2.id GROUP BY table2.id ";

Thank you in advance

arran

1:02 pm on Dec 9, 2005 (gmt 0)

10+ Year Member



Hi s9901470,

Try something like:

SELECT table1.title AS label, SUM(table2.rating) AS total, [b]FORMAT(AVG(table2.rating), 2)[/b] AS mean FROM table1, table2 WHERE table1.id = table2.id GROUP BY table2.id

arran.

s9901470

7:22 pm on Dec 12, 2005 (gmt 0)

10+ Year Member



I get a message saying 'Select Failed!'
Is there a way to find out which part of the syntax is failing?

s9901470

6:29 pm on Dec 15, 2005 (gmt 0)

10+ Year Member



I also want to select the top 10 and bottom 10 ratings. Any suggestions on what syntax to use?

It will read something like "select 10 highest as topten, 10 lowest as bottomten, find corresponding id in table2, print labels with ratings"