Answer the question
In order to leave comments, you need to log in
Can a common table expression (with as) be used twice?
Hello!
Is it possible to use a common table expression twice? If so, how?
//выбираем только 20 строк с ... по ...
with DATAS as (select Id, Name, row_number() over (order by Id) RN from Country )
select * from DATAS where RN between 10 and 30
//считаем сколько всего записей
select count(*) from DATAS
Answer the question
In order to leave comments, you need to log in
Look at the t-sql documentation
.... fetched when executing a simple query and defined in the execution scope of a single SELECT, INSERT, UPDATE or DELETE statement.....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question