Hello. I have the following query:
The query runs fine, but I am trying to insert the results into another table:
I keep getting the error: Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'A'.
How do I need to modify this to insert it into a table?
Thanks!
Brian
Code:
with A as (
select T.pr,T.sa,T.block,T.tlot, r=T.tlot-rank()over(partition by T.pr,T.sa,T.block order by T.tlot)
from (Select pr,CONVERT(INT,lot) tlot,block,sa from lotblock WHERE isnumeric(lot + 'e0') = 1) T
)
select pr,sa,block,MIN(tlot),MAX(tlot)
from A
group by pr,sa,block order by pr,sa,block
The query runs fine, but I am trying to insert the results into another table:
Code:
insert into #temp
with A as (
select T.pr,T.sa,T.block,T.tlot, r=T.tlot-rank()over(partition by T.pr,T.sa,T.block order by T.tlot)
from (Select pr,CONVERT(INT,lot) tlot,block,sa from lotblock WHERE isnumeric(lot + 'e0') = 1) T
)
select pr,sa,block,MIN(tlot),MAX(tlot)
from A
group by pr,sa,block order by pr,sa,block
I keep getting the error: Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'A'.
How do I need to modify this to insert it into a table?
Thanks!
Brian