An XML value. The content is escaped unless the data type is XML. The order-by-expression orders the elements returned by the function.
An expression used to order the XML elements according to the value of this expression.
When an ORDER BY clause contains constants, they are interpreted by the optimizer and then replaced by an equivalent ORDER
BY clause. For example, the optimizer interprets ORDER BY 'a' as ORDER BY expression.
A query block containing more than one aggregate function with valid ORDER BY clauses can be executed if the ORDER BY clauses
can be logically combined into a single ORDER BY clause. For example, the following clauses:
ORDER BY expression1, 'a', expression2
ORDER BY expression1, 'b', expression2, 'c', expression3
Any values that are NULL are omitted from the result. If all inputs are NULL, or there are no rows, the result is NULL. If
you require a well-formed XML document, you must ensure that your query is written so that the generated XML has a single
Data in BINARY, LONG BINARY, IMAGE, and VARBINARY columns is automatically returned in base64-encoded format when you execute
a query that contains XMLAGG.
The following statement generates an XML document that shows the orders placed by each customer.
SELECT XMLELEMENT( NAME "order",
XMLATTRIBUTES( ID AS order_id ),
( SELECT XMLAGG(
XMLATTRIBUTES( ProductID, Quantity AS "quantity_shipped" ) ) )
FROM SalesOrderItems soi
WHERE soi.ID = so.ID
) AS products_ordered
FROM SalesOrders so
ORDER BY so.ID;