On Sun, 09 Nov 2008 15:23:41 +0100, usrobo wrote
Witam!
Mam prośbę o pomocy w modyfikacji zapytania sqlowego
te zapytanie $dbq = $dbase->prepare("SELECT customerid, SUM(uprate) AS uprate, SUM(downrate) AS downrate, SUM(upceil) AS upceil, SUM(downceil) AS downceil FROM assignments, customers, tarifs WHERE customers.id = customerid AND deleted = 0 AND tariffid = tariffs.id AND (datefrom <= $utsfmt OR datefrom = 0) AND (dateto > $utsfmt OR dateto = 0) GROUP BY customerid")
SELECT assignments.customerid AS customerid, SUM(uprate) AS uprate, SUM(downrate) AS downrate, SUM(upceil) AS upceil, SUM(downceil) AS downceil FROM assignments, customers, tarifs LEFT JOIN customerassignments ON customerassignments.customerid = assignments.customerid WHERE customers.id = assignments.customerid AND customergroupid = 3 AND deleted = 0 AND tariffid = tariffs.id AND (datefrom <= $utsfmt OR datefrom = 0) AND (dateto > $utsfmt OR dateto = 0) GROUP BY assignments.customerid
Pozdrawiam.