?
Solved

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

Posted on 2012-12-27
8
Medium Priority
?
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 668 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 664 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
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 32

Accepted Solution

by:
awking00 earned 668 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
 

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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 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