Solved

select (count(job) + job)  from AceData  group by job ??

Posted on 2012-12-27
8
218 Views
Last Modified: 2012-12-30
select (count(job) + job)  from AceData  group by job

using ms sql server

the above not working

want to show,

25 myJob
30 otherjob
01 badjob
0
Comment
Question by:goodk
8 Comments
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 167 total points
ID: 38726121
you mean to say uou need to show job name also

try tghis

select Cast(count(job) as varchar) + '  ' + job  from AceData  group by job
0
 

Author Comment

by:goodk
ID: 38731559
I've requested that this question be deleted for the following reason:

resolved used str() to convert
0
 
LVL 5

Assisted Solution

by:RehanYousaf
RehanYousaf earned 166 total points
ID: 38726399
I dont think using STR function is a good idea unless you want fixed length

I would go with pratima's solution
0
 
LVL 32

Accepted Solution

by:
awking00 earned 167 total points
ID: 38727925
select job, count(*) cnt from AceDate group by job
will give you two columns, if you want them in one, then

select cast(cnt as char) +  ' ' + job as countjobs from
(select job, count(*) cnt from AceDate group by job)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:goodk
ID: 38731504
I tried this, should this be ok?  The results looks fine
Select (type +' ('+ ltrim(str(count(type))) +')' ) as xtest from AceData group by type
0
 

Author Closing Comment

by:goodk
ID: 38731560
thanks
0
 
LVL 5

Expert Comment

by:RehanYousaf
ID: 38731727
Yes that will work but why use to functions when you can get away with one

In programming trick is to make things simple not complicated

Select (type +' ('+ convert(varchar,count(type)) +')' )

Open in new window

0
 

Author Comment

by:goodk
ID: 38731927
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now