ADODB SQL 查询 ORDER BY 子查询不起作用
ADODB SQL Query ORDER BY subquery not working
Classic ASP 中的 VBScript 代码提取包含子查询的值,按该子查询排序不会排序。如何更改此查询以按子查询结果排序?
也试过"ORDER BY 2 ASC;"这不会引发错误但什么都不做
SELECT tblWP.keyWP, (SELECT SUM(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) FROM tblX WHERE tblX.keyWP=tblWP.keyWP) AS t1 FROM tblWP ORDER BY t1;
试试这个:
SELECT
tblWP.keyWP,
(SELECT SUM(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) FROM tblX WHERE tblX.keyWP=tblWP.keyWP) AS t1
FROM
tblWP
ORDER BY
(SELECT SUM(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) FROM tblX WHERE tblX.keyWP=tblWP.keyWP)
您可以试试这个变体:
SELECT
tblWP.keyWP,
Sum(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) AS t1
FROM
tblWP
INNER JOIN
tblX
ON tblWP.keyWP = tblX.keyWPItem
GROUP BY
tblWP.keyWP
ORDER BY
Sum(DateDiff('n',tblX.dtmStart,tblX.dtmEnd));
Classic ASP 中的 VBScript 代码提取包含子查询的值,按该子查询排序不会排序。如何更改此查询以按子查询结果排序?
也试过"ORDER BY 2 ASC;"这不会引发错误但什么都不做
SELECT tblWP.keyWP, (SELECT SUM(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) FROM tblX WHERE tblX.keyWP=tblWP.keyWP) AS t1 FROM tblWP ORDER BY t1;
试试这个:
SELECT
tblWP.keyWP,
(SELECT SUM(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) FROM tblX WHERE tblX.keyWP=tblWP.keyWP) AS t1
FROM
tblWP
ORDER BY
(SELECT SUM(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) FROM tblX WHERE tblX.keyWP=tblWP.keyWP)
您可以试试这个变体:
SELECT
tblWP.keyWP,
Sum(DateDiff('n',tblX.dtmStart,tblX.dtmEnd)) AS t1
FROM
tblWP
INNER JOIN
tblX
ON tblWP.keyWP = tblX.keyWPItem
GROUP BY
tblWP.keyWP
ORDER BY
Sum(DateDiff('n',tblX.dtmStart,tblX.dtmEnd));