下面的查询返回查询中的所有值,但我还需要将查询返回的总行放在一列中。每行中的值可以相同。
我尝试使用COUNT(),但每行返回1。选择中的“ COUNT(A.MRN)作为ReturnedRows”,然后在何处之后“ GROUP BY A.MRN”
select A.STATUS as ASTATUS, A.MRN as StatusMRN,
K.transnumber, K.NRM as PatientMRN, K.DESCRIPTION
from database_name.patientoverlay as K
inner join database_name.patientstatus as A on A.MRN = K.MRN
where A.STATUS like'active' and K.description like '%Overlaypreformed%';
查询返回的内容:
ASTATUS StatusMRN transnumber PatientMRN DESCRIPTION
active 12356789 78000 12356789 Overlay performed
active 12356791 78001 12356791 Overlay performed
active 12356792 78002 12356792 Overlay performed
active 12356793 78003 12356793 Overlay performed
active 12356794 78004 12356794 Overlay performed
我知道Patienttaus表中有110位活跃患者,而他们的MySQL工具指出它返回了110行。
我想得到以下信息:
ASTATUS StatusMRN transnumber PatientMRN DESCRIPTION ReturnedRows
active 12356789 78000 12356789 Overlay performed 110
active 12356791 78001 12356791 Overlay performed 110
active 12356792 78002 12356792 Overlay performed 110
active 12356793 78003 12356793 Overlay performed 110
active 12356794 78004 12356794 Overlay performed 110