日期:2014-05-17  浏览次数:20713 次

急求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
----------------
项目1 1
项目2 1
项目3 1

不是很明白你的意思。ABC表的结构是怎么样的?看是不是这样?