December 4, 2012 at 12:49 pm
how to implment excel fourmula =ROUND((ROW()-1)*D$2,0) into t sql .. ..
December 4, 2012 at 12:54 pm
nikki123 (12/4/2012)
how to implment excel fourmula =ROUND((ROW()-1)*D$2,0) into t sql .. ..
Not 100% sure what you are trying to do here but I think you are trying to implement a running total and round it to 0 decimal places?
The rounding part is very simple. This explains ROUND in sql server.
http://msdn.microsoft.com/en-us/library/ms175003%28v=sql.105%29.aspx
The running total is a bit more challenging. Jeff Moden has an awesome article that explain how to do that here. http://www.sqlservercentral.com/articles/T-SQL/68467/[/url]
If you need specific help coding please see the first link in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
December 4, 2012 at 1:05 pm
We have excel with 4 colums
5 nth select columa column b
10 5.16 103750 20000
16
21
the nth select is basically columa / column b - 5.16
we have to round off that 5.16 - to 5 or 6
and using this round(row-1)*d20
get the value 10
its 1-1= 0 *5
2-1 =1*5= 5
3-1=2*5= 10
December 4, 2012 at 1:09 pm
nikki123 (12/4/2012)
We have excel with 4 colums5 nth select columa column b
10 5.16 103750 20000
16
21
the nth select is basically columa / column b - 5.16
we have to round off that 5.16 - to 5 or 6
and using this round(row-1)*d20
get the value 10
its 1-1= 0 *5
2-1 =1*5= 5
3-1=2*5= 10
No offense but look at what you posted and ask yourself if you think you would have any chance of understanding what you are talking about.
Are you saying you want to multiply the current rowNumber by a variable? For that you would use the ROW_NUMBER function.
If it totally unclear what you are trying to do. I will say it again, if you want specific coding help you need to post some details. ddl (create table scripts), sample data (insert statements) and desired output based on the sample data. See the first link in my signature.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply