Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Nesting SQL?

Posted on 2011-03-08
7
Medium Priority
?
390 Views
Last Modified: 2012-05-11
Hi - I have a number of records with different Analysts assigned in a table and I would like to create a query that returns the record count for each Analyst in the same query but I am not if this can be done. I'm sure it most likely can be but I don't know how to implement it off the top of my head.

For example, I have the query

SELECT count (*) AS JC
FROM QTab
WHERE analyst = 'john cashmere'

How can I add more analysts to the query? For example , I have Bill Mosth, Craig Hany, etc etc

It would be great to get all these counts returned in one query



Thanks for any assistance
0
Comment
Question by:rinkydink
7 Comments
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 35077528
SELECT count (*) AS JC
FROM QTab
WHERE analyst in ( 'john cashmere','analyst2','analyst3')
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 35078253
Can you show the qTab structure? This sounds like a cross-tab query.
0
 
LVL 5

Expert Comment

by:mayankagarwal
ID: 35078662
if you want to count the no. of rows based on the anlyst then you can use the group by clause

SELECT count (*) AS JC
FROM QTab
where  analyst in ( 'john cashmere','analyst2','analyst3')
group by analyst
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:santoshmotwani
ID: 35078688
SELECT count (*) AS JC, analyst
FROM QTab
where  analyst in ( 'john cashmere','analyst2','analyst3')
group by analyst
0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 35080185
I think you want the count of records for every analyst. If so, remove the WHERE condition.
select analyst,count(*) from QTab group by analyst

Open in new window

0
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 35080219
agreed with sharath
0
 
LVL 1

Author Closing Comment

by:rinkydink
ID: 35080458
Perfect! Thank you
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

916 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