I’ve got the following table
mytable
type | id | name | formula
"simple" | 1 | "COUNT" | "<1>"
"simple" | 2 | "DISTINCT" | "<2>"
"simple" | 3 | "mycol" | "<3>"
"complex" | 4 | null | "<1>(<2> <3>)"
Now I would like to read this table and add an additional column which replaces the formula string.
For id 4 I would need: "COUNT(DISTINCT mycol)"
Any idea how I can do that?
In Oracle 11 it may looks like this:
SQL Fiddle