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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|