0
I can not solve this issue, I want it to show number of customers without repeating primary key, no realized deals and show a warning if customers have done business. There was this mistake here.
CREATE FUNCTION sem_negocios() RETURNS integer AS
$$
SELECT count(*), CASE WHEN identidade NOT IN (SELECT DISTINCT identidade FROM negocio)
THEN 'negociado'
ELSE 'nao negociado'
END AS identidade
FROM cliente
GROUP BY CASE
WHEN identidade IN (SELECT DISTINCT identidade FROM negocio)
THEN 'negociado'
ELSE 'nao negociado'
END
ORDER BY identidade;
$$
LANGUAGE 'SQL';
ERROR: column "client.identity" should appear in the GROUP BY clause or be used in an aggregation function LINE 3: SELECT Count(*), CASE WHEN identity NOT IN (SELECT DISTIN... ^
********** Error **********
ERROR: "client.identity" column should appear in the GROUP BY clause or be used in an aggregation function SQL state: 42803 Character: 83
also post the table structure
– Rovann Linhalis