Saturday 15 June 2013

ms access 2010 - Getting an SQL Error while combining aggregate function with list items -



ms access 2010 - Getting an SQL Error while combining aggregate function with list items -

i've started learning sql recently. we're using ms access (2010, in case). no task have list how many workers list called "radnik" work in different company locations (marked "brod"). wrote down:

select brod, count(*) count radnik order brod;

there 18 people in list, of them have values of 10,20,30,40 or 50, should create table, instance, like:

brod | count 10 | 5 20 | 9 ...

i get, error, though: you tried execute query not include specified look 'brod' part of aggregate function. obivously, i'm doing wrong, i'm still new sql. i'd very much appeciate if explain me why doesn't work , how fixed.

you need group by:

select brod, count(*) count radnik grouping brod order brod;

in short: whenever you're using aggregate function count, other selected columns need in group by clause well.

sql ms-access-2010 aggregate-functions

No comments:

Post a Comment