New answers tagged

-1

Before you vote this down look at the question before the major edits This is valid (and good) answer to the original stated question What you have is just messed up Why use a merge for an update only? Why use a CTE when it is the whole table update firms set firms.Total = results.Total from frims join results on firms.firm = results.firm ...


1

As Nickolay explained in his answer, WITH is not allowed in a view definition in Teradata. You can work around the specific problem by using a derived table instead. You can either specify it twice, keeping the union of your query: create view derived_table (derived_column) as select (a||'-'||b) as derived_column from (select a,b,c from table_a ...


3

Contradiction Detection could kick in to make sure only one of the statements is run, and in my simple test it did as long as there was a statement-level recompile hint, but why risk it? For example: USE tempdb GO -- CREATE SCHEMA agg --DROP TABLE agg.DataMin --DROP TABLE agg.DataMedian --DROP TABLE agg.DataWeightedAverage --GO CREATE TABLE agg.DataMin ( ...


0

I think you can easily pile the CTEs on top of each other, like so: WITH ins AS ( INSERT INTO core.adr (street, "number", postal_code, city) VALUES ('test 1', '25a', '00912', 'villageman') RETURNING id), ins2 AS ( INSERT INTO someothertable (id, something) SELECT id, 'something' FROM ins RETURNING id -- this is necessary for CTE, but ...



Top 50 recent answers are included