|
▼安久 さん:
とりあえず…。
SELECT P.saidayの最大 AS 検査日,
dbo_kenkekdt.ukeno AS 受付番号,
P.kancd AS カルテNO,
dbo_kanmf.kjnam AS 患者氏名,
dbo_kenmasf.kensacode AS 検査コード,
dbo_kenmasf.kensaname AS 検査名,
dbo_kenkekdt.kekka AS 検査結果,
dbo_kenmasf.unit AS 単位
FROM (([
SELECT dbo_kenkekdt.kekcode,
Max(dbo_kenkekdt.saiday) AS saidayの最大,
dbo_kenirahd.kancd
FROM dbo_kenkekdt
INNER JOIN dbo_kenirahd ON (dbo_kenkekdt.ukeymd = dbo_kenirahd.ukeymd)
AND (dbo_kenkekdt.ukeno = dbo_kenirahd.ukeno)
GROUP BY dbo_kenkekdt.kekcode, dbo_kenirahd.kancd
]. AS P
INNER JOIN dbo_kanmf ON P.kancd = dbo_kanmf.code)
INNER JOIN dbo_kenmasf ON P.kekcode = dbo_kenmasf.kensacode)
INNER JOIN dbo_kenkekdt ON P.saidayの最大 = dbo_kenkekdt.saiday
GROUP BY P.saidayの最大,
dbo_kenkekdt.ukeno,
P.kancd, dbo_kanmf.kjnam,
dbo_kenmasf.kensacode,
dbo_kenmasf.kensaname,
dbo_kenkekdt.kekka,
dbo_kenmasf.unit;
上記 SQL で患者氏名ごとに最新の検査結果が抽出できないでしょうか?
|
|