急求sql查询ABC三张表中项目一,项目二,项目三各有多少条怎么写呢?
急求sql查询ABC三张表中项目一,项目二,项目三各有多少条怎么写呢?
[解决办法]
select count(*) from A
select count(*) from B
select count(*) from C
Select*,identity(int,1,1) as rn
Into B
From ( Select '项目1' AS p
Union All
select '项目2' Union All
Select '项目3' Union All
select null) as tt
Select p,count(*)
From B
--Where P is not null
Group by p
----------------
项目11
项目21
项目31