select (select sc_machid as ClinicID,
case
when substring(sc_machid,1,3)='BB0' then 'Head Office'
WHEN substring(sc_machid,1,3)='BA0' THEN 'HeadOffice'
when substring(sc_machid,1,3)='BA1' THEN 'Villiers'
when substring(sc_machid,1,3)='BA2' then 'Imperial IDC'
WHEN substring(sc_machid,1,3)='BA3' THEN 'Warden'
WHEN substring(sc_machid,1,3)='BA4' THEN 'Harrismith'
WHEN substring(sc_machid,1,3)='BA5' THEN 'Tugela'
WHEN substring(sc_machid,1,3)='BA6' THEN 'MooiRiver'
WHEN substring(sc_machid,1,3)='bad' THEN 'MooiRiver'
WHEN substring(sc_machid,1,3)='BB0' THEN 'Port Elizabeth'
WHEN substring(sc_machid,1,3)='BB1' THEN 'East London'
when substring(sc_machid,1,3)='BB2' THEN 'Umthatha'
when substring(sc_machid,1,3)='BB3' then 'Kokstad'
WHEN substring(sc_machid,1,3)='BB4' THEN 'Marian Hill'
WHEN substring(sc_machid,1,3)='BB5' THEN 'Zeerust'
WHEN substring(sc_machid,1,3)='BC0' THEN 'Imperial SBD'
WHEN substring(sc_machid,1,3)='BC1' THEN 'Imperial TSD'
WHEN substring(sc_machid,1,3)='BC2' THEN 'Roodekop'
WHEN substring(sc_machid,1,3)='BD0' THEN 'Ventersburg'
WHEN substring(sc_machid,1,3)='BD1' THEN 'Colesburg'
WHEN substring(sc_machid,1,3)='BD2' THEN 'Hanover'
WHEN substring(sc_machid,1,3)='BD3' THEN 'Beaufort West'
WHEN substring(sc_machid,1,3)='BD4' THEN 'Beit Bridge Border Post Musina'
WHEN substring(sc_machid,1,3)='BD5' THEN 'Cape Town - Epping'
WHEN substring(sc_machid,1,3)='BD7' THEN 'Komati Poort'
end as ClinicName, count(TransactionType) as NumberOfFirstTimePatientVisits
from sc_audit
where TransactionType = 'Insert Patient Record'
group by ClinicName)
as t1,
(
select pat_id as PatientID,
count(*) as NumberOfVisits,
sc_clinicid as ClinicID,
CASE
WHEN sc_clinicid = 'BA0' THEN 'HeadOffice'
when sc_clinicid = 'BA1' THEN 'Villiers'
when sc_clinicid = 'BA2' then 'Imperial IDC'
WHEN sc_clinicid = 'BA3' THEN 'Warden'
WHEN sc_clinicid = 'BA4' THEN 'Harrismith'
WHEN sc_clinicid = 'BA5' THEN 'Tugela'
WHEN sc_clinicid = 'BA6' THEN 'MooiRiver'
WHEN sc_clinicid = 'bad' THEN 'MooiRiver'
WHEN sc_clinicid = 'BB0' THEN 'Port Elizabeth'
WHEN sc_clinicid = 'BB1' THEN 'East London'
when sc_clinicid = 'BB2' THEN 'Umthatha'
when sc_clinicid = 'BB3' then 'Kokstad'
WHEN sc_clinicid = 'BB4' THEN 'Marian Hill'
WHEN sc_clinicid = 'BB5' THEN 'Zeerust'
WHEN sc_clinicid = 'BC0' THEN 'Imperial SBD'
WHEN sc_clinicid = 'BC1' THEN 'Imperial TSD'
WHEN sc_clinicid = 'BC2' THEN 'Roodekop'
WHEN sc_clinicid = 'BD0' THEN 'Ventersburg'
WHEN sc_clinicid = 'BD1' THEN 'Colesburg'
WHEN sc_clinicid = 'BD2' THEN 'Hanover'
WHEN sc_clinicid = 'BD3' THEN 'Beaufort West'
WHEN sc_clinicid = 'BD4' THEN 'Beit Bridge Border Post Musina'
WHEN sc_clinicid = 'BD5' THEN 'Cape Town - Epping'
WHEN sc_clinicid = 'BD7' THEN 'Komati Poort'
end as ClinicName
from sc_queue
group by ClinicName
)
as t2;
上面的查询给了我一个错误,上面写着
Operand should contain 1column(s)
请帮助我,我似乎无法弄清楚问题出在哪里