question

g_yerden avatar image
g_yerden asked

Cool Insert Question using Partition

IDK if this is possible or not but I haven't been able to find an answer that quite fits my situation... With cte AS ( SELECT col1, col2, col3, ROW_NUMBER() OVER (PARTITION BY col1,col2,col3 ORDER BY col3) AS coolcol FROM table ) SELECT * FROM cte ... Great, this partitions based on my 3 columns and gives me numbers for each of those. What I want to do is where 'coolrow' = 1 AND 'col3' = 1 to insert a row above with my specified values. I also need to be able to insert different values where 'col3' = 0. Any guidance would be much appreciated, this is cool stuff for me but probably basic for most of you guys. Thanks!
insertctepartitionrow_number
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.