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.
| Author |
Topic |
|
rameshduraikannu
Starting Member
10 Posts |
Posted - 2009-11-23 : 08:10:32
|
| [code]hai to allI have two tables ('admin' and 'user'). These tablescontain among others fields as below.admin(table name) grade 240 270 3000user(table name)Grade value246273301Compare both(240 admin value) and (246 user value) round to nearest to admin value(240)I would like a query that finds the grade (from the admintable) compares it to ' Grade value ' (from user) and returnsthe Grade value [/code].[url]http://www.sqlservercentral.com/Forums/Attachment4582.aspx[/url]rameshduraikannu[code]Create table #admin1 (grade int, a_height int,a_width int)Create table #user1 (grade int, u_heigth int,u_width int)INSERT INTO #admin1 VALUES (2176,200,240)INSERT INTO #admin1 VALUES(2176,260,300)INSERT INTO #admin1 VALUES(2716,260,360)INSERT INTO #user1 VALUES(2176,198,210 )INSERT INTO #user1 VALUES(2176,250,300)INSERT INTO #user1 VALUES(2716,250,350)select * from #user1select * from #admin1[code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-11-23 : 09:09:20
|
| are you using sql 2005? |
 |
|
|
rameshduraikannu
Starting Member
10 Posts |
Posted - 2009-11-23 : 22:31:54
|
quote: Originally posted by visakh16 are you using sql 2005?
quote: i am using sqlserver 2008
rameshduraikannu |
 |
|
|
kbhere
Yak Posting Veteran
58 Posts |
Posted - 2009-11-24 : 02:54:46
|
| Is there any relation between these 2 tables??If so, let me know..Balaji.K |
 |
|
|
rameshduraikannu
Starting Member
10 Posts |
Posted - 2009-11-24 : 04:49:37
|
quote: Originally posted by kbhere Is there any relation between these 2 tables??If so, let me know..Balaji.K
quote: hai balaji i add the sample code this is my table structure.the relation is grade INSERT INTO #admin1 VALUES (2176,200,240)INSERT INTO #admin1 VALUES(2176,260,300)INSERT INTO #admin1 VALUES(2716,260,360)INSERT INTO #user1 VALUES(2176,198,210 )INSERT INTO #user1 VALUES(2176,250,300)INSERT INTO #user1 VALUES(2716,250,350)select * from #user1select * from #admin1
rameshduraikannu |
 |
|
|
|
|
|
|
|