Add Fields to a query that are not included in an aggregate functi

M

Marc

I have a query with aggegated functions.

SELECT Count(Classified) AS TotCnt, Abs(Sum(classified=-1)) AS
TrueCnt_Unclassified, TrueCnt_Unclassified/TotCnt AS
PerCentTrue_Unclassified, Abs(Sum(classified=0)) AS TrueCnt_Active,
TrueCnt_Active/TotCnt AS PerCentTrue_Active
FROM DataTable;

If I wanted to add other fields to the query how to I go about doing that.
For example say I wanted to add the "Date" field to the query. How would I do
that?
Thanks in advance!
 
M

Mike

If you are talking about just adding a new field titled "date"you can add
this to the select statement:

, Date: as ''

That's two single quotation marks.
 
K

KARL DEWEY

Do you mean like this --
SELECT Count(Classified) AS TotCnt, Abs(Sum(classified=-1)) AS
TrueCnt_Unclassified, TrueCnt_Unclassified/TotCnt AS
PerCentTrue_Unclassified, Abs(Sum(classified=0)) AS TrueCnt_Active,
TrueCnt_Active/TotCnt AS PerCentTrue_Active, Date() AS Report_Date
FROM DataTable
GROUP BY TrueCnt_Unclassified/TotCnt, TrueCnt_Active/TotCnt, Date();
 
J

John W. Vinson

I have a query with aggegated functions.

SELECT Count(Classified) AS TotCnt, Abs(Sum(classified=-1)) AS
TrueCnt_Unclassified, TrueCnt_Unclassified/TotCnt AS
PerCentTrue_Unclassified, Abs(Sum(classified=0)) AS TrueCnt_Active,
TrueCnt_Active/TotCnt AS PerCentTrue_Active
FROM DataTable;

If I wanted to add other fields to the query how to I go about doing that.
For example say I wanted to add the "Date" field to the query. How would I do
that?
Thanks in advance!

If your query retrieves multiple records, with multiple date values, what do
you want to see? Or are you talking about displaying today's date?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top