nbiggs wrote:
When I try executing the command I get 'SQL error: near "as": syntax
error'.
Let me explain what I am trying to do, there might be a better way to do
it. I have a table of weights as one of the columns. I am trying to
return data so that I can create a histogram of the data. My query is
as follows:
Select round(field, 1), count(*)
from table
group by round(field, 1);
Nathan,
What version of SQLite are you using? The cast syntax was added fairly
recently. I'm using version 3.2.7 to test.
With a current version of SQLite this should work.
select cast (field * 10 as integer) / 10.0 as bin, count(*)
from table group by bin;
Note, you wont get a result row for any bin values that would have had a
count of zero. I.e. if there are no rows with a value of 49.8?? then
there will not be a result row in the histogram for that value with a
count of zero. The histogram output only has rows where the count was 1
or more. This may or may not be what you want.
HTH
Dennis Cote