W dniu 2011-11-10 17:16, milek pisze:
Tak, na szybkości.......
SELECT customers.id http://customers.id, customers.lastname, customers.name http://customers.name, customers.address, customers.city, customers.zip, tariffs.value, tariffs.period, assignments.dateto, assignments.at http://assignments.at FROM customers LEFT JOIN assignments ON customers.id http://customers.id = customerid LEFT JOIN tariffs ON assignments.tariffid = tariffs.id http://tariffs.id WHERE deleted = 0 AND (customers.status = 3) AND (assignments.invoice = 1) AND (assignments.dateto >= (select now()::abstime::int4) OR assignments.dateto = 0) AND ( (assignments.period=3 and tariffs.value BETWEEN 1 AND 4) and (assignments.period in (4,5) and tariffs.value >= 4 ) ) GROUP BY customers.id http://customers.id, customers.lastname, customers.name http://customers.name, customers.address, customers.city, customers.zip, tariffs.value, tariffs.period, assignments.dateto, assignments.at http://assignments.at;
Ta konstrukcja nie działa prawidłowo niestety (zwraca 0 wierszy).