我有一张桌子
我正在使用以下查询
select max(dblVersion),sName,fCompleted,ixLastModifiedBy,dtCreatedAt,dtLastModifiedAt,fStatus from tblechecklisttemplateversion group by ixTemplate
我得到下表作为输出
其他列的行值不对应dblVersion列..如何显示对应的行值
试试这个
SELECT
a.dblVersion,
a.sName,
a.fCompleted,
a.ixLastModifiedBy,
a.dtCreatedAt,
a.dtLastModifiedAt,
a.fStatus
FROM
tblechecklisttemplateversion a
JOIN (
SELECT
ixTemplate,
max(dblVersion) as dblVersion
FROM
tblechecklisttemplateversion
GROUP BY
ixTemplate) as b
ON
a.ixTemplate=b.ixTemplate and a.dblVersion=b.dblVersion
这可能会帮助你..
更改查询 -
SELECT 0 INTO @x;
select (@x:=@x+1) as
rownumber,max(dblVersion),sName,fCompleted,ixLastModifiedBy,dtCreatedAt,
dtLastModifiedAt,fStatus
from tblechecklisttemplateversion group by ixTemplate