RE: Counting expression doesn't work when sorted by count - Access 200



You can not display individual records and the total count at the same time.
Try this ---
SELECT Count([Works_number] & [BT_SCP] & [Test_code_2]) AS PSCP_Count
FROM Main
GROUP BY [Works_number] & [BT_SCP] & [Test_code_2];

--
KARL DEWEY
Build a little - Test a little


"Pat" wrote:

The following SQL script works fine:

SELECT [Works_number] & [BT_SCP] & [Test_code_2] AS PSCP, Count([PSCP]) AS
Expr1
FROM Main
GROUP BY [Works_number] & [BT_SCP] & [Test_code_2];

However the following SQL script doesn't work. The difference in the two
scripts is the added last line ORDER BY:

SELECT [Works_number] & [BT_SCP] & [Test_code_2] AS PSCP, Count([PSCP]) AS
Expr1
FROM Main
GROUP BY [Works_number] & [BT_SCP] & [Test_code_2]
ORDER BY Count([PSCP]) DESC;

When I try to run the second script, Access comes back with an 'Enter
parameter value' request for PSCP.

I rarely build my queries in SQL as I don't come from an SQL background. I
usually build them in design view. In design view the first query is as
follows:

Field - PSCP: [Works_number] & [BT_SCP] & [Test_code_2]
Total - Group By

Field - Expr1: [PSCP]
Total - Count

and the second query is identical except for the sort, as follows:

Field - PSCP: [Works_number] & [BT_SCP] & [Test_code_2]
Total - Group By

Field - Expr1: [PSCP]
Total - Count
Sort - Descending

Hoping someone can point out my error. I'm guessing my problem lies in
incorrectly assuming the design grid is producing the SQL code I think it
should.

Thanks,
Pat

.



Relevant Pages

  • Re: Counting expression doesnt work when sorted by count - Access
    ... Thanks Michel, works great. ... seems like poor software design. ... However the following SQL script doesn't work. ... I rarely build my queries in SQL as I don't come from an SQL background. ...
    (microsoft.public.access.queries)
  • Table Edit Error
    ... I used a script to create a table in my SQL 2000 DB. ... design table, I can not edit the fields. ...
    (microsoft.public.sqlserver.datawarehouse)
  • Re: SQL
    ... > If you design right, you can *shift* much behavior to being data and ... > SQL is close to being Turing Complete. ... It is a bad habit of yours. ... If you're seriously suggesting that CRUD applications are equal ...
    (comp.object)
  • Re: Hyperlinks
    ... http://www.snipesfamily.net/index_files/DAVE.htm The issue is that Publisher ... the design checker tool will find some of these issues. ... I am betting that you are using a script on your home page that you are not ... I have seen a lot of Publisher produced sites that load ...
    (microsoft.public.publisher.webdesign)
  • Re: notice and warning
    ... You expect some piece of data from a post in your script, ... prefer $_REQUEST over $_POST. ... the different meanings the input should have based on how it arrives. ... that's bad design. ...
    (comp.lang.php)

Loading