Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 08, 2012 05:48 AM by KashifB
Member
503 Points
403 Posts
Dec 07, 2012 09:59 AM|LINK
I am getting following result for a query:
ID DAY_NAME TOTAL 1 Mon 2 1 Tue 5 1 Wed 1 1 Thu 5 1 Fri 0 1 Sat 0 1 Sun 4 2 Mon 7 2 Tue 1 2 Wed 1 2 Thu 0 2 Fri 2 2 Sat 5 2 Sun 0
I am looking to combine the above rows into something like the following:
ID DAY_NAMES TOTAL 1 Mon 2, Tue 5, Wed 1... 17 2 Mon 7, Tue 1, Wed 1... 16
Thanks
All-Star
35557 Points
5696 Posts
Dec 07, 2012 10:53 AM|LINK
try this
Declare @temp as varchar(1000) select ID, (case when @temp is null then '' else @temp + ',' end) + Total as Day_Names, Total from TableName
hope this helps...
Dec 07, 2012 02:46 PM|LINK
Where is @temp assigned the day name? Or does it not have to?
And also, the Total column should be a total of all 7 days.
Dec 08, 2012 05:48 AM|LINK
I'm using MySql, can anyone help with this?
KashifB
Member
503 Points
403 Posts
Combining multiple columns and rows into one (sort of !)
Dec 07, 2012 09:59 AM|LINK
I am getting following result for a query:
I am looking to combine the above rows into something like the following:
Thanks
kedarrkulkar...
All-Star
35557 Points
5696 Posts
Re: Combining multiple columns and rows into one (sort of !)
Dec 07, 2012 10:53 AM|LINK
try this
Declare @temp as varchar(1000) select ID, (case when @temp is null then '' else @temp + ',' end) + Total as Day_Names, Total from TableNamehope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
KashifB
Member
503 Points
403 Posts
Re: Combining multiple columns and rows into one (sort of !)
Dec 07, 2012 02:46 PM|LINK
Where is @temp assigned the day name? Or does it not have to?
And also, the Total column should be a total of all 7 days.
KashifB
Member
503 Points
403 Posts
Re: Combining multiple columns and rows into one (sort of !)
Dec 08, 2012 05:48 AM|LINK
I'm using MySql, can anyone help with this?