如何合併這兩個查詢?我正在寫這個查詢的時間很艱難。兩個查詢在一個
1)
SELECT question_id, name, question_text FROM questions
WHERE ST_Intersects(ST_Buffer(ST_GeomFromText('POINT(-99.254512 19.347091)',
4326)::geography, 1000)::geometry, the_geom)
2)
select q.question_id, COUNT(qa.question_id) as answer_count
from questions q
left join question_answers qa
on qa.question_id = q.question_id
group by q.question_id
(我在SQL一個完整的小白)
有沒有辦法做到這一點。
SELECT
(COUNT(qa.question_id) as answer_count
from questions q
left join question_answers qa
on qa.question_id = q.question_id
group by q.question_id),
question_id, name, question_text FROM questions
WHERE ST_Intersects(ST_Buffer(ST_GeomFromText('POINT(-99.254512 19.347091)',
4326)::geography, 1000)::geometry, the_geom)
感謝=),它的工作。我用了第二個。工作得很好==) –