|
Hello all,
(comments are locked)
|
|
all you have to do to put more columns in is add the column names to the start of the CTE then add the extra columns to the cte query Then for your main select statement, add the columns to that To change the name of the Case statement add as 'RevenueStreamID' after the END Read this to find out about CTE's. The row_number function basically sort the query and adds sequential numbers to the query. It is the best way to solve problems like yours. http://msdn.microsoft.com/en-us/library/ms186734.aspx The case statement simply checks when the revenuestreamID is equal to 7, and changes it to the next value. good luck! I finally figured it out yesterday and got the rows that I needed. Once again Daniel, Thank you. You have been a very big help to me!
May 03 '12 at 02:37 PM
cdurham
(comments are locked)
|
|
I ran the code that you suggested me to run and it works! I modified it a bit:
(comments are locked)
|
|
is there a unique identifier in the table? to get this to work properly, you would need to have a column you can order by , then you could extract the revenueStreamID with a case statement. And use a CTE with a row_number function to get consecutive row numbers. (The unique order in the sample below is ID). Then you can put the results in a temp table, or where ever you like. Just don't use a loop! +1 for "don't use a loop"
May 02 '12 at 11:15 AM
Magnus Ahlkvist
I will have to sort this by invoice number. I have to then sort the revenuestream id in descending order since the 7's from each invoice is the first priority number in an invoice. I will give this code a try when I come to work today. Thank you so much!
May 02 '12 at 11:34 AM
cdurham
There is one more thing I forgot to mention. Could you please put comments by the cte code. I really do not understand what each part is doing. Thanks.
May 02 '12 at 04:05 PM
cdurham
Please ignore my posting on how to insert the cte into a table. I kept working with it and figured it out, but could you please explain the with statement for me please so that i can put comments about what it does in my code? Thanks again.
May 02 '12 at 07:00 PM
cdurham
(comments are locked)
|



