当前位置: 代码迷 >> Sql Server >> 急求sql查询ABC三张表中项目一,项目二,项目三各有多少条如何写呢
  详细解决方案

急求sql查询ABC三张表中项目一,项目二,项目三各有多少条如何写呢

热度:41   发布时间:2016-04-24 21:52:15.0
急求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表的结构是怎么样的?看是不是这样?
  相关解决方案