Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Combine multiple columns

Author  Topic 

lols
Posting Yak Master

174 Posts

Posted - 2008-03-03 : 06:10:09
Hi,

I have the following query :

select uname, count(ID) from tbh_Axis
group by uname

which works fine and displays

Admin	3
User1 8


How can i display the result as :

Admin(3)
User1(8)


When I do this:

select uname + '(' + count(ID) + ')' from tbh_Axis
group by uname

It doesnt work.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-03 : 06:14:48
quote:
Originally posted by lols

Hi,

I have the following query :

select uname, count(ID) from tbh_Axis
group by uname

which works fine and displays

Admin	3
User1 8


How can i display the result as :

Admin(3)
User1(8)


When I do this:

select uname + '(' + cast(count(ID) as varchar(5)) + ')' from tbh_Axis
group by uname

It doesnt work.



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

lols
Posting Yak Master

174 Posts

Posted - 2008-03-03 : 06:28:16
thanks very much
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-03 : 07:34:53
But if you want to show that data in front end application, do the same there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -