举个例子, 以下2句可以合并吗? 否则要执行2次子查询.with t as
(select * from t1)
select count(*) from t;with t as
(select * from t1)
select * from t
(select * from t1)
select count(*) from t;with t as
(select * from t1)
select * from t
with t as
(select * from t1)
select *,(select count(*) from t) cc from t;
(select * from t1)
select t.* , (select count(*) from t) from t
(select * from t1)
, t2 as
(select * from t1)
select * from t2,(select count(*) con from t1)t1
过多CTE引号效率不高,不如直接用临时表代替
SELECT *
FROM t1 ,
( SELECT COUNT(*) rn
FROM t1
) b
--2005
SELECT * ,
COUNT(*) OVER ( ) rn
FROM t1
t-sql写的啰嗦并不代表性能差,而一句能完成的sql,也并不代表性能高,而且往往很差。