MySQL - error mysql

   
Vista:

error mysql

Publicado por alberto garcia (1 intervención) el 13/06/2016 17:40:11
buenas,


tengo el siguiente codigo para verificar las horas extras, pero no me esta funcionando,

el deberia verificar lo siguiente

if start_date <= 6 y end_date >= 21

mostrar el numero '202'

aqui el codigo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
select 0 as consecutivo
    , numero_identificacion as numero_identificacion
, concat(c.name,' ', p.first_name) as analista
    , case when (EXTRACT(hour FROM w.start_date) >= 6 and EXTRACT(hour FROM w.start_date) <= 21)
    and (EXTRACT(hour FROM w.end_date) <= 21
     and EXTRACT(hour FROM w.end_date) >= 6)
     and w.es_extra = 'NO' then '005'
     when (EXTRACT(hour FROM w.start_date) >= 6 and EXTRACT(hour FROM w.start_date) <= 21)
    and (EXTRACT(hour FROM w.end_date) <= 21
     and EXTRACT(hour FROM w.end_date) >= 6)
     and w.es_extra = 'SI' then '212'
     when (EXTRACT(hour FROM w.start_date) >= 22 or EXTRACT(hour FROM w.start_date) <= 5)
        and (EXTRACT(hour FROM w.end_date) <= 5
    or EXTRACT(hour FROM w.end_date) >= 22) and w.es_extra = 'NO' then '206'
    when (EXTRACT(hour FROM w.start_date) >= 22 or EXTRACT(hour FROM w.start_date) <= 5)
        and (EXTRACT(hour FROM w.end_date) <= 5
    or EXTRACT(hour FROM w.end_date) >= 22) and w.es_extra = 'SI' then '018'
    else '000'
    end as concepto
 
    , ( SUM( TIME_TO_SEC( timediff(w.end_date, w.start_date) ) ) - sum((CAST(CAST(w.horas_almuerzo AS char) AS decimal(2,1)) * 3600)) )/3600 as horas
    , 1 as cod1
    , o.code as centro_costo
    , 1 as cod2
 
from ticket t
join workorder w on t.id = w.ticket_id
join organization o on o.id = t.org_id
join ((contact c join person p on c.id = p.id)) on w.owner_id = p.id
left join ticket_incident i on t.id = i.id
left join ticket_request u on t.id = u.id
where 1 = 1
 and [ w.start_date >= {fechainicio,VALUE}  and w.start_date <= {fechafin,VALUE} ]
group by consecutivo
    , numero_identificacion
 , concat(c.name,' ', p.first_name)
    , concepto
    , cod1
    , centro_costo
    , cod2;



ojala me puedan ayudar... gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder