Quantcast
Channel: Questions in topic: "sql-server-2005"
Viewing all articles
Browse latest Browse all 415

logic required

$
0
0
hello all, i am new to development. i had a table where columns we have are idoc no,status,process date time. here the idoc number 1231 in the below table is having status error on 16th 20th and 23rd but it got success state on 25th so i need the idoc numbers which are having errors earlier and succeded finally so that i can delete idocno 1231 with error status. idoc no status process date time 1231 error 16/3/2013 1234 error 16/3/2013 1674 error 15/4/2013 1231 error 20/4/2013 1231 error 23/4/2013 1234 error 16/3/2013 1234 error 17/3/2013 1234 success 25/5/2013 1231 success 25/5/2013 delete from idocstatus where idocNO in( select idocNO, status, accessdatetime from (select idocNO, status, accessdatetime, row_number() over(partition by idocNO order by accessdatetime desc) as rn from idocstatus) as T where rn = 1 and status = 'error') i am using this query but i am getting the error : Msg 116, Level 16, State 1, Line 1 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS

Viewing all articles
Browse latest Browse all 415

Trending Articles