So as the title suggests I need to return the records from a table, where these records can belong to a group. If there are several records in a group, return only the last one, and if the record does not belong to any group, return it together. I have the following tables (automation_execution) 1 –> n (automation_execution_action) 1 <—>
Tag: ruby-on-rails-5
Rails 5 where or active record query
I’m trying to write a query that counts the number of products from a supplier group that are on a specific state or return 0 if it doesn’t have products. This query will only return the count if the …
Ordering records by an association presence
Lets say I have an instructions table which is associated to a surveys table through survey_instructions join table. What I need to achieve is to fetch all instruction records, but ordered by an …
Rails Postgres query, selecting only items that appear in all search params with associations
I’m looking to create a Postgres query based on a few user select params. A user will select a shop and a start and end year. Once submitted I’m would only like to display average prices of items if …