Friday, December 14. 2012count_if aggregateTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
How about<br /> Yes you can do it, but I personally hate casting a bool to an int - it's breaking the boolean abstraction (and I've been told that such a cast is contrary to the Standard). So I think this is at least much more expressive. I usually just do this with conditionals inside my aggregates:<br /> OK, but which would you rather write? I've seen views with dozens of these case expressions. They are all pretty ugly. Yes, this is also something I've blogged about before: http://thombrown.blogspot.co.uk/2010/11/countif-expression.html Interesting, seems there is some demand for it. Maybe we should just add it to core, written in C of course. (I dislike your transition function on a couple of stylistic grounds, though.) If we're talking about changing the core, would it be crazy to add a WHERE clause to aggregate functions, similar to the existing ORDER BY, so for example COUNT(* WHERE relkind IN ('r','v','S'))? The SQL standard actually has a syntax for that:<br /> Interesting. I didn't know that. Thanks. Please do work on it. |
My Links etcBlog AdministrationCalendar
QuicksearchArchivesCategories |
|||||||||||||||||||||||||||||||||||||||||||||||||