我有一张桌子
我使用以下查询
select max(dblVersion),sName,fCompleted,ixLastModifiedBy,dtCreatedAt,dtLastModifiedAt,fStatus from tblechecklisttemplateversion group by ixTemplate
我将下表作为输出
其他列的行值与dblVersion列不对应。如何显示相应的行值
答案 0 :(得分:1)
试试这个
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
答案 1 :(得分:0)
这可能对你有帮助..
MySQL - Get row number on select
更改了查询 -
SELECT 0 INTO @x;
select (@x:=@x+1) as
rownumber,max(dblVersion),sName,fCompleted,ixLastModifiedBy,dtCreatedAt,
dtLastModifiedAt,fStatus
from tblechecklisttemplateversion group by ixTemplate