Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General »

Problemas con sentencia SQL

Estas en el tema de Problemas con sentencia SQL en el foro de Bases de Datos General en Foros del Web. Podria alguien ayudarme con esta sentencia?? select a.rfc,b.nombre,c.programa from (select rtrim(ltrim(rfc)) as rfc,case inc.idinc when 'I4' then 'R' end as tipo, str(datepart(month,fech_inc),2,0)+ case(str(convert(day,fech_inc),2,0)/16) when 0 ...
  #1 (permalink)  
Antiguo 28/09/2004, 11:38
Avatar de Itankai  
Fecha de Ingreso: abril-2004
Ubicación: conkal, yucatan
Mensajes: 184
Antigüedad: 20 años
Puntos: 0
Problemas con sentencia SQL

Podria alguien ayudarme con esta sentencia??

select a.rfc,b.nombre,c.programa
from (select rtrim(ltrim(rfc)) as rfc,case inc.idinc when 'I4' then 'R' end as tipo,
str(datepart(month,fech_inc),2,0)+ case(str(convert(day,fech_inc),2,0)/16) when 0 then 1 when 1 then 2 when 2 then 1 end as qna from incidencias inc
where ltrim(rtrim(inc.idinc)) ='I4' and fech_inc between convert(datetime,'01/01/2004',103) and
convert(datetime,'31/12/2004',103)-1 group by idinc, datepart(month,fech_inc) +
case str(convert(day,fech_inc),2)/16 when 0 then 1 when 1 then 2 when 2 then 1 end, ltrim(rtrim(rfc))
having count(case idinc when 'I4' then 'R' end)>3
union
select ltrim(rtrim(rfc)) as rfc,
case idinc when 'I1' then 'F' when 'I2' then 'F' when 'I3' then 'F' end as tipo,
str(datepart(month,fech_inc),2,0) + case str(datepart(day,fech_inc),2,0)/16 when 0 then 1 when 1 then 2 when 2 then 1 end as qna
from incidencias inc where (rtrim(ltrim(inc.idjus))= NULL or ltrim(rtrim(inc.idjus))='JF') and inc.idinc <>'I4' and
fech_inc between convert(datetime,'01/01/2004',103) and convert(datetime,'31/12/2004',103)-1
group by idinc,
datepart(month,fech_inc)+case(str(datepart(day,fec h_inc),2,0)/16) when 0 then 1 when 1 then 2 when 2 then 1 end,rtrim(ltrim(rfc)),
(select rfc,apellido1 +' ' +apellido2 +' '+ nombre as nombre,idprog from catperso) ,
(select idprog,programa from catprog) where rtrim(ltrim(a.rfc))=* ltrim(rtrim(b.rfc)) and ltrim(rtrim(b.idprog))= ltrim(rtrim(c.idprog))
group by a.rfc,nombre,programa order by rfc


me marca los siguientes errores.. y kisiera saber como corregirlos...

De antemano... gracias
__________________
De antemano... Gracias.
  #2 (permalink)  
Antiguo 28/09/2004, 12:03
Avatar de Itankai  
Fecha de Ingreso: abril-2004
Ubicación: conkal, yucatan
Mensajes: 184
Antigüedad: 20 años
Puntos: 0
Sorry, estos son los errorres q me marca:

Server: Msg 144, Level 15, State 1, Line 16
No se pueden usar agregados ni subconsultas en las expresiones de la lista de agrupación de la cláusula GROUP BY.
Server: Msg 156, Level 15, State 1, Line 17
Sintaxis incorrecta cerca de la palabra clave 'where'.
__________________
De antemano... Gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:13.