Problem z skomplikowanym zapytaniem SQLa
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
Po krotce moze opisze oco chodzi.. Chce wylistowac wszystkich klientow nalezacych do okreslonych grup, oprocz tych co naleza do jednej oddzielnej i maja saldo rozne od zera.
_______________________________________________ lms mailing list lms@lists.lms.org.pl http://lists.lms.org.pl/mailman/listinfo/lms
uczestnicy (1)
-
ICE