0

我在以下子查询内部选择中有两个。我想划分(subquery1/subquery2)两个子查询。你怎么做呢?

Select subquery1/subquery2,subquery1,subquery2 From.....

谢谢...

4

1 回答 1

2

好吧,如果你有 SQL Server 2005 或更高版本,你可以这样做

select
    SQ.s1 / SQ.s2, SQ.s1, SQ.s2
from table as t
    outer apply (select subquery1 as s1, subquery2 as s2) as SQ

如果你有 SQL 2000 那么你可以使用子查询:)

select
    SQ.s1 / SQ.s2, SQ.s1, SQ.s2
from
(
    select subquery1 as s1, subquery2 as s2
    from table as t
) as SQ
于 2012-11-09T07:56:35.050 回答