mysql - To cast or not to cast? -


i developing system using mysql queries written programmer, , adapting code.

i have 3 questions:

1.

one of queries has select statement:

select    [...]    avg(mytable.foo, 1) 'myaverage'`,  

is 1 in avg(mytable.foo, 1) 'myaverage' legitimate? can find no documentation support usage?

2.

the result of gives me average values 2 decimal places, why?.

3.

i using create temp table. so:

(select     [...]     avg(`mytable`.`foo`, 1) `myaverage`,     [...]     [...] group     [...]) union (select     [...]     [...]     [...] group     [...]) ) `tmptable` order     `tmptable`.`myaverage` desc 

when sort table on column output indicates average being stored string, result like:

9.3

11.1

in order around should use?

should using cast or convert, decimal (which read binary), binary itself, or unsigned?

or, there way state myaverage should integer when name in statement?

something like:

select     avg(myaverage) `myaverage`, int(10) 

thanks.

just who's interested, must have deleted or changed predecessors code avg question incorrect. correct code round(avg(myaverage),1). apologies scrathed heads on stupidity.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -