我们可以在group子句中使用相关子查询吗?

时间:2018-07-27 10:48:14

标签: sql ms-access

我有一个表t2,其中字段Col&a,b,c,d,e为记录。我正在尝试获得如下输出:

r1      0   1
1       b   a
2       d   c
4       e

当我使用以下查询时出现错误:表达式中的语法错误((((从t2中选择Count(b.Col)+1为b,其中a.col> b.col)+1)\ 2 < / p>

Transform
first(col) as col1
Select  ((Select Count(b.Col)+1 from t2 as b where a.col>b.col)+1)\2 as r1
From t2 as a
Group  by (((Select Count(b.Col)+1 from t2 as b where a.col>b.col)+1)\2)
Pivot
(Select Count(b.Col)+1 from t2 as b where a.col>b.col) MOD 2

1 个答案:

答案 0 :(得分:1)

我不这么认为。只需使用子查询:

CefSharp (WPF)

或者,因为您仅选择不同的值,所以在原始查询中使用select r1 from (select a.*, (Select Count(b.Col)+1 from t2 as b where a.col>b.col)+1)\2 as r1 from t2 as a ) as a1 group by r1; 而不是select distinct