Click here to Skip to main content
15,868,349 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a table which contain CompanyId,CandidateId,SendingDate,Status.
So i want to update Status on the basis of Companyid,CandidateId And Order by SendingDate.
how its possible?
please anyone have any about this?
Posted
Comments
Thava Rajan 20-Jun-14 1:02am    
if my solution is not enough to you tell me the exact example and give some sample data

Learn and adapt from this example[^]
 
Share this answer
 
Your question is a little unclear, but assuming your database is MSSQL, something like this might work:
SQL
UPDATE targetTable
SET Status = 'New Status Value'
WHERE  Companyid = 'Your Company ID'
AND CandidateId = 'Your Candidate ID';

SELECT CompanyId,CandidateId,SendingDate,Status
FROM targetTable
ORDER BY SendingDate;


Hope it helps.
 
Share this answer
 
Comments
sushil7350 19-Jun-14 14:25pm    
i want To Update Status On The Basis Of Companyid,Candidateid And Order By Sendingdate. i have some duplicate record also.i want to update Status on basis of latest Sendingdate
see this example [^]

SQL
;with cte as(
  select Dtid, dt, Row_number() over (order by Dt) as rn from test
  )
update cte set DTid =rn;

like wise you can update your table too
 
Share this answer
 
declare @Id int
select @Id=max(Companyid) from table where Companyid=4
update table set status =2 where Companyid=@Id
 
Share this answer
 
SQL
declare @Id int
select @Id=max(Companyid) from table where Companyid=4
update table set status =2 where Companyid=@Id
 
Share this answer
 
Comments
CHill60 14-Jul-14 10:28am    
Why have you reposted your solution from 9 days ago?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900