如何像这样在 Rails 中编写子查询?:
select
m.field1,
m.field2,
(select count(*) from details1 d1 where d1.id=m.field3) as count1,
(select count(*) from details2 d2 where d2.id=m.field4) as count2,
(select count(*) from details3 d3 where d3.id=m.field5) as count3
from
master m
数据库服务器是 PostgreSQL。