Combine Select Statements ?

  • Thread starter Thread starter HeartSA
  • Start date Start date
H

HeartSA

Select Count(*) AS CountAll from Data
Select Count(*) AS CountSome from Data where Individual = Name

I would like to combine this into one statement and give me both the
CountAll and CountSom
 
Create a query field like Some:Iif([individual]=[Name],1,0)

Then SUM that field in your query instead of SUM. IF there is no match,
there will be nothing added to the SUM. If ther is, you will get a one.
You can use this technique to get all sorts of different conditional
Counts in one query.
 
Dear Heart:

SELECT TOP 1
(SELECT Count(*) From Data)
AS CountAll,
(SELECT Count(*)
FROM Data
WHERE Individual = Name)
AS CountIndividual
FROM Data

How is this?

Tom Ellison
 
Create a query field like Some:Iif([individual]=[Name],1,0)

Then SUM that field in your query instead of COUNT. IF there is no match,
there will be nothing added to the SUM. If ther is, you will get a one.
You can use this technique to get all sorts of different conditional
Counts in one query.
 
Back
Top