次のクエリはうまくいきますが、問題は常に結果を返します。空のセットを返すことはありません。 SELECT sum(vmin_consumed) AS vmin
FROM usageinfo
WHERE job_end_time BETWEEN '2017-03-14' AND '2017-03-30'
AND username='tytyjt'
任意の条件が満たされない場合、それはNUL
私はを最初に取得しようとしていますここではactive=1を返し、jsonを返します。 # GET /banners.json
def index
@banners = Banner.where(active: '1').first
end
これは空の配列[]を返します。 私が変更して行う場合Banner.Allすべてのデータを正しく返します
select *
from table1 t1,
table2 t2,
table3 t3
where t2.parent_id = t1.row_id
and t2.xyz is not null
and (
select count(*)
from table3
where xyz = t2.row_id