> What you need is > > COUNT(DISTINCT some_function_that_joins_all_args(arg, arg)) > > because you really want "4,5" to be counted distinctly from "4,6". > So coalesce definitely doesn't do it.
Right, It seems like a simple concat (pg operator ||) would work in this case: SELECT COUNT(t1.a_id || t1.b_id) I have tested this in Pg 8.1 and it works well - the concatenation operator automatically casts numeric types to text, so this satisfies the case of mixed column types representing a primary key. If any of the column values are NULL, concatenation will return NULL and the row will not be counted. If this doesn't fit the bill I'll just avoid counting M-to-M and just count entries in the mapping table. Cheers, Derek ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object