Some functions allow the * notation in an aggregation function, such as:
SELECT COUNT(*) FROM sales
And other functions allow a DISTINCT modifier within the function call, such as:
SELECT COUNT(DISTINCT IF(x > 0, x, NULL)) FROM sales
My question is if any functions allow for the notation of:
SELECT function(DISTINCT *)
CodePudding user response:
No, except for the specific case of COUNT(), you can't use * in function arguments.
Stored functions take a fixed number of arguments.
Some built-in functions (for example, CONCAT() or COALESCE()) take a variable number of arguments, but you must spell them out when you call the function.
I looked in the parser code for MySQL, and found these cases of the use of the '*' symbol:
COUNT(*)orCOUNT(ALL *)orCOUNT(DISTINCT *)SELECT * ...orSELECT ident.* ...DELETE * ...INSERT INTO ident (ident.*) ...SHOW COUNT(*) WARNINGSorSHOW COUNT(*) ERRORSGRANT ... ON *orGRANT ... ON ident.*orGRANT ... ON *.*- Arithmetic multiplication operator
