G
G
Goshujin2022-02-22 03:01:48
SQLite
Goshujin, 2022-02-22 03:01:48

Why if in SELECT * add COUNT() will show one row?

SELECT * from a table will print multiple rows of data, but SELECT *, COUNT() will only print the first row with COUNT() at the end. How to remove * from table by adding COUNT?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2022-02-22
@Goshujin

Because it COUNT()is an aggregate function.
Group by any column, and as a result there will be exactly as many rows as there are unique values ​​in this column, and the COUNT count will be based on these values. Without grouping, the count will be for the entire sample.
Or do separate requests an output of lines and counting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question