Skip to content
Advertisement

Tag: common-table-expression

Cannot use a CTE in a scalar subquery in Db2

I’m trying to use a CTE in a DB2 LUW v11.5.4.0 scalar subquery, but this doesn’t work: I’m getting this error: SQL Error [42601]: An unexpected token “AS” was found following “1 IN ( WITH t (x)”. Expected tokens may include: “JOIN”.. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.26.14 Can this be done? Is there a workaround? (This is similar but not the same

How can I write a SQL query to calculate the quantity of components sold with their parent assemblies? (Postgres 11/recursive CTE?)

My goal To calculate the sum of components sold as part of their parent assemblies. I’m sure this must be a common use case, but I haven’t yet found documentation that leads to the result I’m looking for. Background I’m running Postgres 11 on CentOS 7. I have some tables like as follows: And a view like so, which is

Advertisement