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 |
rintus
Starting Member
26 Posts |
Posted - 2008-09-04 : 14:21:33
|
Suppose I have two tables and I want to select certain attributes and want to compare two of the attributes and generate another column in the result set if the attributes are equal than no and if not than yes. For example - select a.name, a.roll_no, b.name, b.subject from a, bwhere a.row_id = b.row_idI want to compare if a.name <> b.name than 'Yes' else 'No' and this result should be displayed in the result set of the select statement above. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-04 : 14:29:06
|
[code]select a.name,a.roll_no,b.name,b.subject,case when a.name <> b.name then 'Yes' else 'No' end as yourcolumnnamefrom ajoin bon a.row_id = b.row_id[/code] |
 |
|
rintus
Starting Member
26 Posts |
Posted - 2008-09-04 : 14:43:47
|
Thanks a lot :) |
 |
|
|
|
|