So i have question:
SELECT worker_ID as widp, DAYS, MAX(ID_WERSJI) max , funcion1 as FUN1,function2 as FUN2,function3 as FUN3,function4 as FUN4,function5 as FUN5
FROM `grafik201105`
WHERE
funcion1 IN ('one','two','three','four','five','six') OR
function2 IN ('one','two','three','four','five','six') OR
function3 IN ('one','two','three','four','five','six') OR
function4 IN ('one','two','three','four','five','six') OR
function5 IN ('one','two','three','four','five','six') AND
active=1
GROUP BY widp, FUN1,DAYS) as dni
And now i need to get fun1,fun2,fun3,fun4 and fun5 in one column (‘give_me_all’)
AND! in fun1=’one’ replace ‘one’ to ‘first’, if ‘two’ then second, three => third…
i try to use if(fun1=’one’,’first’,fun1) but I think that better solution here is to use CASE but i don’t know exactly how to use it
Well to combine two or more columns into one you just simply do
(function1+function2+function3+function4+function5) AS give_me_all, but as I said, the best should would be to make a function for you to replaceonetofirstand it would then go like(change(function1)+change(function2)+change(function3)+change(function4)+change(function5)) AS give_me_all, but writing a function is a more advanced thing. Try reading more here.Otherwise it will look ugly, but still possible
See how bad it looks? Better learn to write your own function 🙂