SQL Server Performance Forum – Threads Archive
Combine Not Exact RowsI have some rows that have been manipulated a great deal, and I am down to the last couple of edits.
Basically, I get 2 rows (possibly 3) that have almost the exact same data except for 1 field (YR2005). The data may be X, X* or <blank>.
How can I combine these with some criteria?
Mainly, if there is a plain X in any of the rows where ICD9 is same, then that is the row to use. If there is not a plain "X", then, if there is a row with "X*", that row should be used? Here is some data to peruse: YR2005 YR2004 YR2003 Code Desc Severity pt
—— —— —— —- —— ——– ———
X X X 250 DB W/O 0.201 516676401
X* X X 250 DB W/O 0.201 516676401
Post some sample data and the result you want Madhivanan Failing to plan is Planning to fail
Sample data you have given is not sufficient and it’s not clear how the way you want your result to be. Better load more data and expected result from that data and then give a shout.
Sounds like a case for CASE to me. [<img src=’/community/emoticons/emotion-1.gif’ alt=’‘ />]<br />But to be sure you should provide, table structure and sample data.<br /><br />–<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Ich unterstÃ¼tze PASS Deutschland e.V. <a target="_blank" href=http://www.sqlpass.de>http://www.sqlpass.de</a>) <br />