• Luis Cazares (2/20/2015)


    Does this return any rows?

    select *

    from orders o

    JOIN stop first_stop on o.first_stop_id = first_stop.id

    JOIN sales s ON o.id = s.reference

    WHERE s.dis IN( 'a', 'b', 'c')

    AND o.status = 'D'

    AND first_stop.actual_departure >= {ts '2015-01-01 00:00:00'}

    AND first_stop.actual_departure <= {ts '2015-01-31 23:59:59'}

    If it does, the complete query should return discounts. If it doesn't, you don't have data available.

    I got it figured out. Thanks a lot for your help on this!