Flag records based on service date

Please see attached excel file for sample data.
I want to mark records from the same customer as Index / ReIndex  (in the service_type column) based on the following rule:

Flag all records with svc_order =1 as 'Index' in Service_type column.

If customer_id is same
and svc_order>1
and DateDiff in days (svc_start_date for previous record where svc_order = svc_order-1, same customer_id) <=30

Then Flag it as Re-Index.

Attached sample data in excel file.
service_Type column will be initially null and updated as mentioned in the above logic.

How can I accomplish this using sql?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
UPDATE myTable
SET service_type =
      WHEN svc_order = 1 THEN 'Index'
      WHEN DATEDIFF(DAY, myTablePrev.svc_start_date, myTable.svc_start_date) <= 30 THEN 'RE-Index'
FROM myTable
LEFT OUTER JOIN myTable AS myTablePrev
   ON myTable.customer_id = myTablePrev.customer_id
   AND myTable.svc_order = myTablePrev.svc_order + 1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
patd1Author Commented:
Awesome. Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.