I have this query:
select datediff(minute,ti.dtupdated, getdate()) as 'Minutes Old',ti.dtCreated,ti.sTicket_Number,ti.dblTotal,
from tickets as ti
inner join vehicles as ve on ve.lVehicleID = ti.lVehicleID
where datediff(day,dtupdated, getdate()) < 1 and datediff(minute,dtupdated, getdate()) > 15 and bPaid=0 and dbltotal>2 and SUSERNAME is not null
and (bDeleted=0 or bDeleted is null)
It returns results for unpaid tickets. However if the ticket vehicleid shows up again in the same day, I don't want to return any records.