Skip to main content

Posts

Showing posts with the label Pulling a Row Prior to Maximum Row in sql

Splitting a String to a Certain Position,Pulling a Row Prior to Maximum Row,Update in Table in sql

Splitting a String to a Certain Position  substring('abc/123',charindex('abc/123','/')+1,3) Pulling a Row Prior to Maximum Row in sql SELECT    es.emp_employee_id    ,MAX(es.emp_stat_eff_dte) FROM emp_status es WHERE es.emp_stat_eff_dte <    (    SELECT       max(es2.emp_stat_eff_dte)    FROM emp_status es2    WHERE es2.emp_employee_id=es.emp_employee_id    ) order by es.emp_employee_id Update Table from Select Statement in sql To Update Table from Select Statement in sql you can see below example. E.g. update customers CUST set CUST.likes_us = 'Y' where CUST.link_id in  (select distinct REST.link_id   from restaurant REST   where REST.rest_type = 'Diner') and CUST.likes_us is null