我在查询中找不到错误:
SELECT
u.Table_Name,
count(distinct c.Column_Name),
sum(u.num_rows)
FROM User_Tab_Columns c, User_Tables u
WHERE u.TABLE_NAME = c.TABLE_NAME
group by u.Table_Name;
结果是:
TABLE_NAME COUNT(DISTINCTC.COLUMN_NAME) SUM(U.NUM_ROWS)
------------------------------ ---------------------------- ---------------
DEPT 3 12
EMP 8 112
它应该是:
TABLE_NAME COUNT(DISTINCTC.COLUMN_NAME) SUM(U.NUM_ROWS)
------------------------------ ---------------------------- ---------------
DEPT 3 4
EMP 8 14
所以查询多个行数和列数但我不知道为什么?