Temat: postgresql
CET ERROR: column "discount" does not exist at character 823
CET STATEMENT: SELECT c.id AS id, UPPER(lastname) || ' ' || c.name AS customername,
status, address, zip, city, countryid, countries.name AS country, email, ten, ssn, c.info AS info,
message, c.divisionid, c.paytime AS paytime, COALESCE(b.value, 0) AS balance,
COALESCE(t.value, 0) AS tariffvalue, s.account, s.warncount, s.online,
(CASE WHEN s.account = s.acsum THEN 1
WHEN s.acsum > 0 THEN 2 ELSE 0 END) AS nodeac,
(CASE WHEN s.warncount = s.warnsum THEN 1
WHEN s.warnsum > 0 THEN 2 ELSE 0 END) AS nodewarn
FROM customersview c
LEFT JOIN countries ON (c.countryid = countries.id) LEFT JOIN (SELECT
SUM(value) AS value, customerid
FROM cash
GROUP BY customerid
) b ON (b.customerid = c.id)
LEFT JOIN (SELECT a.customerid,
SUM((CASE a.suspended
WHEN 0 THEN (CASE discount WHEN 0 THEN (CASE WHEN t.value IS NULL THEN l.value ELSE t.value END)
ELSE ((100 - discount) * (CASE WHEN t.value IS NULL THEN l.value ELSE t.value END)) / 100 END)
ELSE (CASE discount WHEN 0 THEN (CASE WHEN t.value IS NULL THEN l.value ELSE t.value END) * 0 / 100
ELSE (CASE WHEN t.value IS NULL THEN l.value ELSE t.value END) * discount * 0 / 10000 END) END)
* (CASE t.period
WHEN 3 THEN 1
WHEN 5 THEN 1/12.0
WHEN 7 THEN 1/6.0
WHEN 4 THEN 1/3.0
ELSE (CASE a.period
WHEN 3 THEN 1
WHEN 5 THEN 1/12.0
WHEN 7 THEN 1/6.0
WHEN 4 THEN 1/3.0
ELSE 0 END)
END)
) AS value
FROM assignments a
LEFT JOIN tariffs t ON (t.id = a.tariffid)
LEFT JOIN liabilities l ON (l.id = a.liabilityid AND a.period != 0)
WHERE (a.datefrom <= EXTRACT(EPOCH FROM CURRENT_TIMESTAMP(0))::integer OR a.datefrom = 0) AND (a.dateto > EXTRACT(EPOCH FROM CURRENT_TIMESTAMP(0))::integer OR a.dateto = 0)
GROUP BY a.customerid
) t ON (t.customerid = c.id)
LEFT JOIN (SELECT ownerid,
SUM(access) AS acsum, COUNT(access) AS account,
SUM(warning) AS warnsum, COUNT(warning) AS warncount,
(CASE WHEN MAX(lastonline) > EXTRACT(EPOCH FROM CURRENT_TIMESTAMP(0))::integer - 600
THEN 1 ELSE 0 END) AS online
FROM nodes
WHERE ownerid > 0
GROUP BY ownerid
) s ON (s.ownerid = c.id)
WHERE c.deleted = 0 ORDER BY customername asc
ktoś wie co mogło pójść nie tak? i podpowiedziec jak naprawic ten blad przy imporcie bazy