SQL - count (*)

Franck Nsungu Lukanda 86 Reputation points
2022-03-16T13:56:12.277+00:00

Hello,

Here is my sql query:

select last_name, first_name
count (*)
from actor
group by last_name,
first_name
order by 3 desc

When running it I have an syntax error message around "count (*)":

LINE 2: count (*)
^
SQL state: 42601
Character: 37

Can you please help me? Thanks!

Azure Database for PostgreSQL
0 comments No comments
{count} votes

Accepted answer
  1. GeethaThatipatri-MSFT 27,972 Reputation points Microsoft Employee
    2022-03-16T18:04:07.97+00:00

    Hi, @Franck Nsungu Lukanda Welcome to Microsoft Q&A Thanks for posting your query.
    Can you please try as below, comma is missing after first_name.

    select last_name, first_name,
    count (*)
    from actor
    group by last_name,
    first_name
    order by 3 desc

    Regards
    Geetha


1 additional answer

Sort by: Most helpful
  1. Franck Nsungu Lukanda 86 Reputation points
    2022-03-17T08:41:23.977+00:00

    Hi @GeethaThatipatri-MSFT , it works.
    Thanks for the explanation!