Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nesting SQL?

Posted on 2011-03-08
7
Medium Priority
?
383 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
[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
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

730 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