Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 round the nearest value

Author  Topic 

rameshduraikannu
Starting Member

10 Posts

Posted - 2009-11-30 : 06:21:08
http://www.sqlservercentral.com/Forums/Attachment4582.aspx

rameshduraikannu

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-11-30 : 06:40:46
Sorry, can you post your question here as I and other will not want to open/save a document posted elsewhere.

Thanks
Go to Top of Page

rameshduraikannu
Starting Member

10 Posts

Posted - 2009-11-30 : 07:01:12
quote:
Originally posted by RickD

Sorry, can you post your question here as I and other will not want to open/save a document posted elsewhere.

Thanks



quote:

hai to all

I have two tables ('admin' and 'user'). These tables
contain among others fields as below
.
admin

Location grade
1 240
2 270
1 300
Compare both and round to nearest to admin value(240)


user

Location Grade value
1 246
1 273
2 301


I would like a query that finds the grade (from the admin
table) compares it to ' Grade value ' (from user) and returns
the Grade value




rameshduraikannu
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-30 : 07:15:37
What have you tried so far?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rameshduraikannu
Starting Member

10 Posts

Posted - 2009-11-30 : 08:06:16
quote:
Originally posted by madhivanan

What have you tried so far?

Madhivanan

Failing to plan is Planning to fail



quote:

Select * from (
Select u.*, a.grade as nearest, Row_number()OVER(PArtition by
grade_value order by ABS(grade_value - grade)) as row_num
from #admin a CROSS JOIN #user u) t
where row_num = 1




rameshduraikannu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-30 : 09:44:34
so what should be output out of your sample data?
Go to Top of Page
   

- Advertisement -