What I want to achieve:
WITH summary AS (
SELECT f.* ,
ROW_NUMBER() OVER(PARTITION BY f.name
ORDER BY f.version DESC) AS rk
FROM files f WHERE f.user_id = 1 and f.is_deleted IS FALSE)
SELECT s.*
FROM summary s
WHERE s.rk = 1"
This query works as a RAW SQL. But I am unable to get f.*, row_number()
together on Sequel. I only get row_number() for select. Also a little help
on writing this query like above (for surrounding by WITH) is appreciated.
So far tried:
TableModel.select{Sequel[:reserves].*
}.select{row_number.function.over(partition: object_name, order:
version.desc).as(:rk)}.where(... # i did not finish the query.
How do I make sure f* and row number as rk get together with surrounded
WITH on Sequel query builder? Or should I use raw?
Thanks,
-Gencer.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.