This topic is locked

Problem with SQL Queries

2/22/2006 4:37:58 PM
ASPRunnerPro General questions
M
mtichenor author

Trying to do a select count () statement where we can use a variable (such as report date) to return a count of results.
select count (
) ,

[calldate],

[CallResultCode]

From [dbo].[tablename]

group by calldate, callresultcode
bombs out when I run it, any answers?

Sergey Kornilov admin 2/22/2006

Grouping doesn't work with selecting all fields. Only fields that appear in GROUP BY clause or with an aggregate function applied may appear in select list.
More info and examples:

http://www.xlinesoft.com/articles/interact...BY_&_HAVING.htm

S
swelsh 2/23/2006

Here is what we are trying to do, maybe you have a good solution:
The data in our table may look something like this-
date code

02/12/2006 ANS

02/12/2006 ANS

02/12/2006 X02

02/12/2006 ANS

02/13/2006 U01

02/13/2006 S01

02/13/2006 S01
What we need is to be able to see a count of the codes searchable by date, so if I wanted to know how many different codes we had on 02/12/2006 it would look like this:
ANS 3

X02 1
We are seriously considering purchasing a few copies and this is one of our last barriers.

B
berkeleyjw 3/2/2006

Shawn,
I'm not sure where you are trying to use this select statement or what the error is.
As a rule of thumb, I always use:

select fieldA, fieldB, count(1) as countfield

from table

group by fieldA, fieldB
if you are trying to use something like this in an ASPRunner list page (i.e. listing the data only) then I would try to set up a query/view on your backend and then build the ASPRunner page off that. Disable any add, edit, etc. pages from being build.
If you need to use this list to actually "drill down" to records you can edit, then set this view as the parent record of the table you need to edit (of course you would need to make sure the common field is in both records).
I hope I am understanding this correctly.