Hi,
I have 'marks' table which holds up- & down- votes:
create_table(:marks) do
primary_key :id
foreign_key :user_id, :users, null: false
foreign_key :checklist_id, :checklists, null: false
unique [:user_id, :checklist_id]
Integer :vote, default: 0 # can be -1, 0, 1
end
I want to add a column 'votes_up' (the total number of upvotes from all
users) to a query result:
SELECT *, (
SELECT COUNT(*)
FROM marks
WHERE ((marks.checklist_id = checklists.id)
AND (vote = 1))
) votes_up
FROM checklists
WHERE blah-blah
This works, but is it possible to translate that SQL into Sequel's DSL?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.