sql查询来计算行数

时间:2022-01-04 14:58:29

i have a table like this

我有一张这样的桌子

enter image description here

在此处输入图像描述

2 个解决方案

#1


0  

this will return you number of records in a table:

这将返回表中的记录数:

select count(*) from tablename;

#2


0  

SELECT
    base.*, aaa.the_count
FROM
    TABLE base
INNER JOIN (
    SELECT
        GROUP,
        count(*) AS the_count
    FROM
        TABLE
    GROUP BY
        1
) aaa ON aaa. GROUP = base. GROUP

#1


0  

this will return you number of records in a table:

这将返回表中的记录数:

select count(*) from tablename;

#2


0  

SELECT
    base.*, aaa.the_count
FROM
    TABLE base
INNER JOIN (
    SELECT
        GROUP,
        count(*) AS the_count
    FROM
        TABLE
    GROUP BY
        1
) aaa ON aaa. GROUP = base. GROUP