DB2 Comma Separated Output by Groups

LISTAGG function is new function in DB2 LUW 9.7 see example: create table myTable (id int, category int); insert into myTable values (1, 1); insert into myTable values (2, 2); insert into myTable values (5, 1); insert into myTable values (3, 1); insert into myTable values (4, 2); example: select without any order in grouped … Read more

Mysql SELECT CASE WHEN something then return field

You are mixing the 2 different CASE syntaxes inappropriately. Use this style (Searched) CASE WHEN u.nnmu =’0′ THEN mu.naziv_mesta WHEN u.nnmu =’1′ THEN m.naziv_mesta ELSE ‘GRESKA’ END as mesto_utovara, Or this style (Simple) CASE u.nnmu WHEN ‘0’ THEN mu.naziv_mesta WHEN ‘1’ THEN m.naziv_mesta ELSE ‘GRESKA’ END as mesto_utovara, Not This (Simple but with boolean search … Read more

Avg of a Sum in one query

I think your question needs a bit of explanation. If you want to take the sums grouped by t.client you can use: SELECT t.client, SUM(t.asset) FROM the-table t GROUP BY t.client Then, if you want to take the average of this sume, just make: SELECT AVG(asset_sums) FROM ( SELECT t.client, SUM(t.asset) AS asset_sums FROM the-table … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)