在DB View中返回布尔类型而不是整数

时间:2017-11-01 19:07:18

标签: sql oracle

我的数据库视图包含以下语句:

SELECT
  adherence_date,
  patient_id,
  sum(case when scheduled_time = 'morning'   then nvl2(acknowledged_at,1,0) end) as morning,
  sum(case when scheduled_time = 'afternoon' then nvl2(acknowledged_at,1,0) end) as afternoon,
  sum(case when scheduled_time = 'evening'   then nvl2(acknowledged_at,1,0) end) as evening,
  sum(case when scheduled_time = 'night'     then nvl2(acknowledged_at,1,0) end) as night
FROM medication_adherences
GROUP BY adherence_date, patient_id

以下列格式返回记录:

[0] #<AdherenceActivity:0x007fec986b5328> {
        :adherence_date => Wed, 01 Nov 2017,
            :patient_id => 10000,
               :morning => 1.0,
             :afternoon => 1.0,
               :evening => 0.0,
                 :night => nil
    }

1 == true0 == falsenil表示尚无数据

我希望将早晨,下午,晚上或晚上视为布尔而不是整数。这是SUM函数的结果,还是我的ORM的问题?如果它是由SUM函数引起的,我怎么能让它返回一个布尔值而不是一个整数?

0 个答案:

没有答案