A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old February 25th, 2010, 04:41 PM posted to microsoft.public.access.queries
marc
external usenet poster
 
Posts: 288
Default Add Fields to a query that are not included in an aggregate functi

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!
  #2  
Old February 25th, 2010, 05:05 PM posted to microsoft.public.access.queries
mike
external usenet poster
 
Posts: 3,942
Default Add Fields to a query that are not included in an aggregate functi

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.

"Marc" wrote:

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!

  #3  
Old February 25th, 2010, 06:01 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Add Fields to a query that are not included in an aggregate functi

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();

--
Build a little, test a little.


"Marc" wrote:

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!

  #4  
Old February 25th, 2010, 06:33 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Add Fields to a query that are not included in an aggregate functi

On Thu, 25 Feb 2010 08:41:03 -0800, Marc
wrote:

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?
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.