cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sonney <>
Subject Re: <sql:count-attribute>
Date Thu, 18 May 2000 15:28:44 GMT
On Thu, 18 May 2000, Sebastien Koechlin I-VISION wrote:
> Yes, sorry, I mean
> 	SELECT COUNT(DISTINCT firstname) FROM status;
> which is wrong, example:
> 	bob		yellow
> 	bob		green
> 	joe		yellow
> 	bob		yellow
> SELECT DISTINCT firstname, lastname FROM status
> 	would return 3 rows,
> but SELECT COUNT(DISTINCT firstname) FROM status
> 	would return 2.

According to your data there are only two distingy firstnames, which makes
the results of the second query correct (bob and joe). However, should the
query be :

SELECT COUN(DISTINCT firstname, lastname) FROM status

you should get a return value of 3 (bob green, bob yello, and joe yellow).  

Now, unless you're trying to indicate that the SQLTagLib is running 


instead of 

SELECT COUNT(DISTINCT firstname, lastname) FROM status;

but I'd want to see the generated code to see how that's happening.

> But, I just look at the CSV tree and it's not the same:
> 	SELECT DISTINCT firstname, lastname FROM status
> is translated into
> 	SELECT (*) FROM status;

Which allows for all distinct row in the table. 

> PostgreSQL does not allow this, the interactive client does the same
> error.

Hmm. I'll have to check the SQL docs I've got for legality. dno't think
you *CAN* order a SELECT COUNT(*) query, as it doesn't really return
multiple rows. 

> It works with Oracle, but is it a valid SQL92 (or other) query ?

I can't seem to find anything to indicate ythat it is. I'll put together a
patch and pass ti along to the list(s) for testing.

- Kevin Sonney

View raw message