sql server 2个查询结果相除
selectcount(*)asafromtable1selectcount(*)asbfromtable2如何让查询的结果相除?...
select count(*) as a from table1
select count(*) as b from table2
如何让查询的结果相除? 展开
select count(*) as b from table2
如何让查询的结果相除? 展开
3个回答
展开全部
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
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
展开全部
select a.a/b.b from (
select count(*) as a from table1) a,
(select count(*) as b from table2) b
select count(*) as a from table1) a,
(select count(*) as b from table2) b
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select TOP 1 (select count(*) as a from table1) / (select count(*) as b from table2) from table1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |