0
I need to build a query that removes duplicates from a custom column (concatenated) if a given column is X value. For example:
SELECT emp, cod, vev, gru, concat(cast(emp as char(20)), cast(cod as char(20))) as RES
from hcov
CASE
WHEN GRU = 212 THEN GROUP BY RES END
I tried to assemble this query but error:
SQL Error [700]: [Elevate Software][ElevateDB] ElevateDB Error #700 An error was found in the statement at line 4 and column 4 (Expected end of expression but instead found WHEN)
Basically, what I need is to remove duplicates from the concatenated column only if the GRU column is 212.
sorry I’m a little layman on this subject, I don’t know if this way will help me because I posted here an example of the query, in fact what will go into production the concatenated column would have 6 fields and not only 2 as I did in the summary here.. would have some other logic to this case?
– Fernando Fefu
I believe that the amount of concatenated columns will not affect the result, the important thing is you put a column that does not duplicate where in the example is the emp column. try running some tests to see what happens
– imex
any column can duplicate... what I need is for the query to use the concatenated column to check if it has duplicity when the GRU is 212.. and if there is only bring one.. for the other GRU should even bring duplicates.. understood?
– Fernando Fefu
Is there a column or set of columns in the table that does not duplicate? Which database and version are you using?
– imex