Solved

Nesting SQL?

Posted on 2011-03-08
7
299 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
Comment Utility
SELECT count (*) AS JC
FROM QTab
WHERE analyst in ( 'john cashmere','analyst2','analyst3')
0
 
LVL 26

Expert Comment

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

Expert Comment

by:mayankagarwal
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 16

Expert Comment

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

Accepted Solution

by:
Sharath earned 500 total points
Comment Utility
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
Comment Utility
agreed with sharath
0
 
LVL 1

Author Closing Comment

by:rinkydink
Comment Utility
Perfect! Thank you
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

9 Experts available now in Live!

Get 1:1 Help Now