Rank in MySql
sql_query = ("WITH latest AS ("
" SELECT rev.*,"
" RANK() OVER (PARTITION BY rev.product_api_id "
" ORDER BY published_at DESC"
" ) rank_published_at"
" FROM product_api_setting_revisions rev"
" WHERE product_api_id IN :product_api_ids"
" AND status != 'draft'"
")"
"SELECT * FROM latest WHERE rank_published_at = 1;")
Comments
Post a Comment