Nesting SQL?

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
LVL 1
rinkydinkAsked:
Who is Participating?
 
SharathConnect With a Mentor Data EngineerCommented:
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
 
santoshmotwaniCommented:
SELECT count (*) AS JC
FROM QTab
WHERE analyst in ( 'john cashmere','analyst2','analyst3')
0
 
jerryb30Commented:
Can you show the qTab structure? This sounds like a cross-tab query.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
mayankagarwalCommented:
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
 
santoshmotwaniCommented:
SELECT count (*) AS JC, analyst
FROM QTab
where  analyst in ( 'john cashmere','analyst2','analyst3')
group by analyst
0
 
santoshmotwaniCommented:
agreed with sharath
0
 
rinkydinkAuthor Commented:
Perfect! Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.