Hello,
I have a table with the following fields:
- id
- name
In my query, I want to display the values of both of these fields for each row, but also display how many times each unique name appears. For example, how many rows have the name "Bob". To do this, I'm using the COUNT function, but it's not working! Here is my SQL statement:
SELECT DISTINCT [id], [name], COUNT([bid]) AS total FROM people;
When I run this query, I get the following error:
"You tried to execute a query that does not include the specified expression 'id' as a part of an aggregate function
The result should look like this:
id - name - total
--------------------------------
1 - Bob - 2
2 - Dan - 4
3 - Eric - 1
Can anyone help me with this?
I have a table with the following fields:
- id
- name
In my query, I want to display the values of both of these fields for each row, but also display how many times each unique name appears. For example, how many rows have the name "Bob". To do this, I'm using the COUNT function, but it's not working! Here is my SQL statement:
SELECT DISTINCT [id], [name], COUNT([bid]) AS total FROM people;
When I run this query, I get the following error:
"You tried to execute a query that does not include the specified expression 'id' as a part of an aggregate function
The result should look like this:
id - name - total
--------------------------------
1 - Bob - 2
2 - Dan - 4
3 - Eric - 1
Can anyone help me with this?