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 |
|
anjali5
Posting Yak Master
121 Posts |
Posted - 2011-11-11 : 22:16:37
|
| I have this table number UID updates Message_date InitialDate category 2004061 21449 0 2004-10-06 1900-01-01 1 2004061 21449 1 2004-10-06 1900-01-01 6 2004061 21449 2 2004-10-06 1900-01-01 7 2009345 21344 1 2010-11-09 2011-01-01 1 2009345 21344 1 2010-11-09 2011-01-01 2 2009345 21344 1 2010-11-09 2011-01-01 3 2008988 21333 1 2010-11-09 2011-01-01 3 2008988 21333 1 2010-11-09 2011-01-01 3 2008988 21333 1 2011-11-09 2011-01-01 3for the above table, if the number and UID are same then if the updates are same and message dates(per row) are same then I need to merge that recordso from the above tableI need to merge the record that has number 2009345 and UID 21344 to only one recordso i will get. the number of records will be reduced from 3 to 1 for number 2009345 and UID 21344, other records will be deleted 2009345 21344 1 2010-11-09 2011-01-01 3if the updates and mdate are different then I have to go with the higheset categoryso from the above table, i will get only one record other records will be deleted 2004061 21449 1 2004-10-06 1900-01-01 6If the category is same then I will go with the higheset message date and drop other records. This is for number 2008988 and UID 21333 2008988 21333 1 2011-11-09 2011-01-01 3other records will be deleted.How can I achieve thisThanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-12 : 05:15:04
|
| sorry you explanation and output doesnot always make senseyou've said as below if the updates and mdate are different then I have to go with the higheset categoryand then output shows record with category 6 which is not highest(7 is highest category) can you explain this difference?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|