我有一个查询,它将显示所有选定的记录,除了 MAX 记录(每个查询最多可以有 5 条记录)。但是,它显示在单独的行上。如何在一行中显示结果?
当前数据:
John Smith
Jack Smith
Gerald Smith
一行中的所需数据(或在单独的字段中但不是多行):
约翰·史密斯; 杰克史密斯;杰拉德·史密斯
SQL 语句:
SELECT distinct /*all existing records */
rtrim(ltrim(pn.sFirstName + ' ' + pn.uLastName)) as record1,
'' as record2,
'' as record3,
'' as record4,
'' as record5
FROM tenant t (nolock)
INNER JOIN person pn (nolock) on pn.hmy = t.person
WHERE pn.hmy <>
(SELECT MAX(pn.hmy)
FROM tenant t (nolock)
INNER JOIN person pn (nolock) on pn.hmy = t.person
WHERE t.scode = '111111'
)and t.scode = '111111'
谢谢你的帮助!