Solved

Nesting SQL?

Posted on 2011-03-08
7
327 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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 40

Accepted Solution

by:
Sharath earned 500 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

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.

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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 …

786 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