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 |
|
Rachel1976
Starting Member
1 Post |
Posted - 2006-11-12 : 21:09:38
|
| I have a table, multiple columns, thousands of rows.Six of the columns is the data that i need to work with...col1, col2, col3, col4, col5, col6col1 and col2 - go together - example. col1 = amount col2 = descriptioncol3 and col4 - go together col3 = amount col4 descriptioncol5 and col6 - go together col5 amount and 6 descriptioni need to pull search the table based on an auto number "id" and pull in the necessary two columns that correspond with a set value in the description.example:if col4 has "fee applied" in the description i need to pull the amount.Please help...Thank you in advance |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-12 : 21:49:32
|
Don't quite understand what you really want.Is it this ?select col1, col2, col3, col4, col5, col6from tablewhere id = @id Try posting some sample data and the result that you want KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-11-13 : 06:41:38
|
| Your table structure seems denormalised. Can you also post table structure in addition to sample and expected data?MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-13 : 06:55:28
|
Something like thisSELECT CASE WHEN col2 = @WantedDescription THEN col1 WHEN col4 = @WantedDescription THEN col3 WHEN col6 = @WantedDescription THEN col5 END [Amount], CASE WHEN col2 = @WantedDescription THEN col2 WHEN col4 = @WantedDescription THEN col4 WHEN col6 = @WantedDescription THEN col6 END [Description]FROM YourTableWHERE ID = @SomeID Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|