我对使用plsql查询Oracle非常陌生。假设我有以下数据集:
Doctor | Patient
A | John
A | Amy
B | Alex
B | Jane
B | Brian我如何对患者进行计数,以便将数据转换为:
Doctor | Count of Patient
A | 2
B | 3我认为查询应该是这样的:
select doctor, count(patient)
from table A发布于 2014-09-25 05:51:15
select
doctor, count(*)
from
tablea
group by doctor发布于 2014-09-25 07:46:27
充其量完全猜测here...psuedo代码
select (columns), a.counter
from yourcurrentjoins
inner join (select
doctor, count(*) as counter
from
tablea
group by doctor) a
on yourcurrentjoin.doctor = a.doctor这将允许您在添加所需的count列时,将a.counter作为select statement...preserves中的列、原始逻辑和所需的所有列进行引用。
https://stackoverflow.com/questions/26027061
复制相似问题