On Wed, 07 Nov 2007 15:03:47 +0100, ICE wrote
Baza: Postgres
Zapytanie:
SELECT inet_ntoa(ipaddr) AS ip, ROUND(COALESCE(SUM(value), 0.00)/COUNT(DISTINCT nodes.id),2) AS balance, customers.lastname AS llastname, customers.id AS iid, customers.name AS nname, customers.address AS aaddress, customers.city AS ccity, customerassignments.customergroupid AS ggrup FROM nodes JOIN customers ON (ownerid = customers.id) JOIN cash ON (cash.customerid = customers.id) JOIN customerassignments ON (customerassignments.customerid = customers.id) WHERE ( customerassignments.customergroupid = 3 OR customerassignments.customergroupid = 5 OR customerassignments.customergroupid = 25 OR customerassignments.customergroupid = 1 OR customerassignments.customergroupid = 7 OR customerassignments.customergroupid = 27 OR customerassignments.customergroupid = 2 OR customerassignments.customergroupid = 6 OR customerassignments.customergroupid = 26 OR customerassignments.customergroupid = 31 OR customerassignments.customergroupid = 32 OR ( customerassignments.customergroupid = 4 AND balance != 0 ))
GROUP BY ipaddr, customers.id, customers.lastname, customers.name, customers.address, customers.city, customerassignments.customergroupid ORDER BY ipaddr;
Wyrzuca mi komunikat ERROR: column "balance" does not exist
w WHERE nie możesz użyć nazwy kolumny utworzonej w zapytaniu.
_______________________________________________ lms mailing list lms@lists.lms.org.pl http://lists.lms.org.pl/mailman/listinfo/lms