S
S
Sergey2019-10-03 12:04:34
Transact SQL
Sergey, 2019-10-03 12:04:34

How to write the result of a complex query to a table?

There is a table with sales by day. It naturally has a huge number of lines. From this table, I form a PIVOT to group sales by month. I do this with a complex query where months are dynamically determined from a date, columns for PIVOT are formed from them, and the result is displayed. Essence of the question. There is a second table in which I need to enter the result of this PIVOT. Is it possible at all. I naturally know about INSERT INTO SELECT. This works well when it comes to SELECT FROM WHERE. And here is a huge request in which variables are declared at the beginning. And INSERT immediately swears that it is waiting for the SELECT construct.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2019-10-03
@googlgan

Put your request in a procedure. Documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question