|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
![]() I'm new in SQL. I have a big problem ![]() Database: MSSQL 2000 I have two tables: (results) one with numeric results and one with names (importance_scale) SELECT * FROM results name i1 i2 i3 i4 i5 ---- ---- ---- ---- ---- john 2 1 2 2 2 anna 0 2 2 2 2 phil 2 2 2 2 2 dave 1 0 2 2 2 SELECT * FROM importance_scale imp_value imp_name --------- ------------ 2 very important 1 important 0 not important i1,i2 etc. value it is a imp_value from table 'importance_scale' I would like to make report which will show all results in this format (in example only first record): name i1 i2 i3 i4 i5 etc. ----- --- --- --- --- --- john very important important very important very important very important etc. I was thinking about using CASE I don't want use cursor. What is the best way? Thanks for your help ![]() |
|
#2
|
||||
|
||||
|
Code:
select name
, n1.imp_name as imp1
, n2.imp_name as imp2
, n3.imp_name as imp3
, n4.imp_name as imp4
, n5.imp_name as imp5
from results
inner
join importance_scale as n1
on i1 = n1.imp_value
inner
join importance_scale as n2
on i2 = n2.imp_value
inner
join importance_scale as n3
on i3 = n3.imp_value
inner
join importance_scale as n4
on i4 = n4.imp_value
inner
join importance_scale as n5
on i5 = n5.imp_value
|
|
#3
|
|||
|
|||
|
Big Thanks!!! This is exactly what I was looking for
![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > name lookup 5 times |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|