Pesquisar na Comunidade
Mostrando resultados para as tags ''turno''.
Encontrado 1 registro
-
Olá Pessoal, Estou tendo que ajustar o início do turno de alguns funcionários, porém estou com muita dificuldade. Segue abaixo a situação: +---------------------------------+--------------------------------+-------------+-----------------+ | STARTTIME | ENDTIME |ATIVIDADE|FUNCIONARIO| +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-01 22:00:00.000 |2013-01-02 01:00:00.000 | xbc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-02 01:00:00.000 |2013-01-02 02:50:00.000 | ihc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-02 02:50:00.000 |2013-01-02 03:00:00.000 | uwc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-02 03:00:00.000 |2013-01-02 03:30:20.000 | abc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-02 03:30:20.000 |2013-01-02 04:00:00.000 | dbc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-02 04:00:00.000 |2013-01-02 05:20:00.000 | auc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-04 20:00:00.000 |2013-01-04 20:50:00.000 | xbc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-04 20:50:00.000 |2013-01-04 23:17:00.000 | ihc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-04 23:17:00.000 |2013-01-05 01:10:00.000 | uwc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 01:10:00.000 |2013-01-05 02:32:20.000 | abc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 02:32:20.000 |2013-01-05 04:00:00.000 | dbc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 04:00:00.000 |2013-01-05 04:43:00.000 | auc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 17:22:50.000 |2013-01-05 18:00:00.000 | uwc | y | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 18:00:00.000 |2013-01-05 18:32:40.000 | abc | y | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 18:32:40.000 |2013-01-05 19:00:00.000 | dbc | y | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-05 19:00:00.000 |2013-01-05 20:23:53.000 | auc | y | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-08 23:40:00.000 |2013-01-09 03:40:40.000 | abc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-09 03:40:40.000 |2013-01-10 00:05:00.000 | dbc | x | +---------------------------------+--------------------------------+-------------+-----------------+ |2013-01-10 00:05:00.000 |2013-01-10 03:00:58.000 | auc | x | +---------------------------------+--------------------------------+-------------+-----------------+ Eu tenho atualmente a situação acima, porém preciso criar um campo "INICIO_TURNO" e dar um UPDATE conforme a situação abaixo: +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ | STARTTIME | ENDTIME |ATIVIDADE|FUNCIONARIO| INICIO_TURNO | +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-01 22:00:00.000 |2013-01-02 01:00:00.000 | xbc | x |2013-01-01 22:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-02 01:00:00.000 |2013-01-02 02:50:00.000 | ihc | x |2013-01-01 22:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-02 02:50:00.000 |2013-01-02 03:00:00.000 | uwc | x |2013-01-01 22:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-02 03:00:00.000 |2013-01-02 03:30:20.000 | abc | x |2013-01-01 22:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-02 03:30:20.000 |2013-01-02 04:00:00.000 | dbc | x |2013-01-01 22:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-02 04:00:00.000 |2013-01-02 05:20:00.000 | auc | x |2013-01-01 22:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-04 20:00:00.000 |2013-01-04 20:50:00.000 | xbc | x |2013-01-04 20:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-04 20:50:00.000 |2013-01-04 23:17:00.000 | ihc | x |2013-01-04 20:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-04 23:17:00.000 |2013-01-05 01:10:00.000 | uwc | x |2013-01-04 20:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 01:10:00.000 |2013-01-05 02:32:20.000 | abc | x |2013-01-04 20:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 02:32:20.000 |2013-01-05 04:00:00.000 | dbc | x |2013-01-04 20:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 04:00:00.000 |2013-01-05 04:43:00.000 | auc | x |2013-01-04 20:00:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 17:22:50.000 |2013-01-05 18:00:00.000 | uwc | y |2013-01-05 17:22:50.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 18:00:00.000 |2013-01-05 18:32:40.000 | abc | y |2013-01-05 17:22:50.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 18:32:40.000 |2013-01-05 19:00:00.000 | dbc | y |2013-01-05 17:22:50.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-05 19:00:00.000 |2013-01-05 20:23:53.000 | auc | y |2013-01-05 17:22:50.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-08 23:40:00.000 |2013-01-09 03:40:40.000 | abc | x |2013-01-08 23:40:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-09 03:40:40.000 |2013-01-10 00:05:00.000 | dbc | x |2013-01-08 23:40:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ |2013-01-10 00:05:00.000 |2013-01-10 03:00:58.000 | auc | x |2013-01-08 23:40:00.000| +---------------------------------+--------------------------------+-------------+-----------------+--------------------------------+ Poderiam me ajustar a criar uma lógica para atualizar o campo "INICIO_TURNO", conforme mencionado acima no SQL SERVER 2012? Observação: Existem diversos funcionários (X, y, z, ...), e pode ou não existir turnos que atravessam o dia conforme mencionei nos exemplos.