
Oracle SUM Function
Add up values per group with SUM, total intervals of time in Oracle AI Database 26ai, and handle NULLs and empty groups correctly.
Posts tagged AI-Assisted are created with support from artificial intelligence. I use AI tools to research, draft, and refine ideas—combining human insight with machine precision to deliver clear, informed, and creative content.

Add up values per group with SUM, total intervals of time in Oracle AI Database 26ai, and handle NULLs and empty groups correctly.

Learn the difference between COUNT(*), COUNT(column), and COUNT(DISTINCT), and how to count matches correctly after an outer join.

Store TRUE and FALSE in BOOLEAN columns, select conditions as values, and group, sort, and test BOOLEAN data safely with IS TRUE.

Turn values and objects into XML documents with Oracle's SYS_XMLGEN, rename them with XMLFormat, and aggregate them with SYS_XMLAGG.

Compare two XML documents, list the changed nodes as xdiff operations, and rebuild the new version from the old one with XMLPATCH.

Apply XSLT stylesheets to XML inside the database with XMLTRANSFORM, turning table data into HTML, text, or another XML layout.

Convert XML to indented or compact text of the type you need with XMLSERIALIZE, and parse text into XMLType documents or fragments.

Convert XML query results into SQL numbers, dates, and strings with XMLCAST, and avoid the trap of paths that match several nodes.

Test whether an XML document contains an element or value, and filter rows in WHERE by the content of their XML with bound variables.

Run XQuery paths, functions, and FLWOR expressions against XML inside SQL with XMLQUERY, and turn results into values or text.

Shred XML documents into relational rows and typed columns with XMLTABLE, including attributes, row numbers, and namespaced XML.

Join XML values into one fragment with XMLCONCAT, and create comments, processing instructions, and CDATA sections in SQL.

Aggregate the rows of each group into ordered XML child elements, and nest XMLAGG calls to build a complete document in one query.

Turn table rows into well-formed XML elements with XMLELEMENT, add attributes with XMLATTRIBUTES, and create element runs with XMLFOREST.

List every subset of a collection, or only the pairs or triples, with POWERMULTISET and POWERMULTISET_BY_CARDINALITY.

Gather the values of each group into a nested table collection with COLLECT and CAST, and avoid the ORA-00932 element type mismatch.

Remove duplicate elements from a nested table collection, the collection version of DISTINCT, and use it after MULTISET UNION.

Count the elements of a nested table collection in SQL, and see how empty collections, NULL collections, and NULL elements behave.