Author |
Topic |
jamiesw
Starting Member
6 Posts |
Posted - 2014-02-25 : 14:27:32
|
Hi therei have some sql that i also need to merge several fields into one. any helpers please I need to merge all the columns i have the CASE against so it will output a coloumn with the values.thanksjamieSELECT SUM(total) AS SumOftotal, Code, tbl_years_lookup.year,CASE FSG_UK WHEN 0 THEN '' WHEN 1 THEN 'UK'END AS UK, CASE FSG_IntWHEN 0 THEN '' WHEN 1 THEN 'INT'END AS INT, CASE FSG_EU WHEN 0 THEN '' WHEN 1 THEN 'EU'END AS EU,CASE FSG_SCWHEN 0 THEN '' WHEN 1 THEN 'SC'END AS SC,title, modename, YearofProgFROM tbl_Background_Details INNER JOIN tbl_years_lookup ON tbl_Background_Details.Year_id = tbl_years_lookup.years_idGROUP BY tbl_Background_Details.Year_id,tbl_Background_Details.Code, tbl_Background_Details.Title,tbl_Background_Details.modename,tbl_Background_Details.YearofProg, tbl_Background_Details.Recruitment_Year,tbl_Background_Details.FSG_UK, tbl_Background_Details.FSG_Int,tbl_Background_Details.FSG_EU, tbl_Background_Details.FSG_SC,tbl_years_lookup._yearHAVING (tbl_Background_Details.code = @code)ORDER BY tbl_Background_Details.Code |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-02-25 : 19:00:23
|
I'm not clear on what you want as an output. Can you show an example? Are you just trying to concatenate the UK, INT, EU and SC columns together?===============================================================================There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber (1894-1961) |
|
|
jamiesw
Starting Member
6 Posts |
Posted - 2014-02-26 : 03:10:03
|
Thanks for replying. The output would be something like;i am getting stuck due to the CASE statements i have to change the bit field to string.SumOfTotal,Code,Year,FSG_Grp,title,modename,YearofProg15, AV34, 2012, UK,My Title, Mode 1, 201312, AV78, 2011, INT, My Title, Mode 2, 201212, AV67, 2013, SC, My Title, Mode 3, 201445, AV23, 2009, EU, My Title, Mode 1, 2010 |
|
|
|
|
|