|
I query table from DB2 there are six fields I want tot match item to the previous record and if the cost field is differetn then in is added to the temp table What is the best way to do this in SQL SERVER 2008 R2?
(comments are locked)
|
|
There are many ways to get the results you need. In case if you simply need to reveal all records for the same item which don't have the same cost then you can simply group by whatever column make up the item and then include only those which have different prices (those will obviously have minimum and maximum of the price different), for example: Hope this helps, Oleg
(comments are locked)
|


@jaymz69 Which non-matching record do you need to add to the temp table (first or second)? What about if there are 3 records for the same date, co, loc, po and item?
I would take any records when the cost != cost
@jaymz69 Please let me know what do you consider "same item"? Is it just the item column or something else is involved?