Answers for "sql in rails"

SQL
2

rails execute sql

results = ActiveRecord::Base.connection.exec_query(sql)
Posted by: Guest on November-10-2020
0

rails sql query converstion

SmsMessage.where(
        sms_campaign_id: sms_campaign_ids
      ).select(
        "sum(CASE WHEN sms_messages.status = 1 THEN 1 ELSE 0 END) as enqueued_count",
        "sum(CASE WHEN sms_messages.status = 2 THEN 1 ELSE 0 END) as delivered_count",
        "sum(CASE WHEN sms_messages.status = 3 THEN 1 ELSE 0 END) as replies_count",
        "sum(CASE WHEN sms_messages.status = 4 THEN 1 ELSE 0 END) as failed_count",
        "sum(CASE WHEN sms_messages.status IN (1,2,4) THEN 1 ELSE 0 END) as sends_count",
        "count(id) as total_messages_count"
      )
Posted by: Guest on October-12-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language