永发信息网

sql server 2个查询结果相除

答案:3  悬赏:20  手机版
解决时间 2021-02-26 10:32
  • 提问者网友:骑士
  • 2021-02-25 22:41
sql server 2个查询结果相除
最佳答案
  • 五星知识达人网友:白昼之月
  • 2021-02-25 23:22
declare @a float
declare @b float
select @a= count(*) from table1
select @b = count(*) from table2
select @a/@b

楼上的方法,如果只是COUNT条数,没有小数点啊。。。 要转格式:
select a.a/b.b from
(select cast(count(*)as float) as a from table1) as a,
(select cast(count(*)as float) as b from table2) as b
全部回答
  • 1楼网友:荒野風
  • 2021-02-26 01:36
select TOP 1 (select count(*) as a from table1) / (select count(*) as b from table2) from table1
  • 2楼网友:掌灯师
  • 2021-02-26 00:07
select a.a/b.b from (
select count(*) as a from table1) a,
(select count(*) as b from table2) b
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯