1
我有了一個名爲type
列其持有的兩個詞upvote
或downvote
我想通過a.question_id組再得2列,其中每一一個計數一個表。選擇從1數分列成2列
select a.*, u.* from answers a
left join users u using(user_id)
left join vote_history v using(answer_id)
where a.question_id = 4 and deleted < 4
group by v.question_id
order by votes desc
例選擇
ColumnA | ColumnB | upvotes | downvotes
---------+----------+---------+----------
record1A | record2B | 3 | 2
record2A | record2B | 2 | 5
是否有可能爲我做這件事而不做多個查詢,並沒有做一個子查詢?