Subject | How could I reimplemente this Query... |
---|---|
Author | Carlos Ortiz Quiros |
Post date | 2005-09-13T15:41:02Z |
Hi
As I have come across with this query in one of my
applications which I have ported recently from
Microsoft Access to FB (1.5.2, which does not support
Derived tables)
SELECT A.idUsuario, F.szNombre TutorName,
F.szApellidos TutorSurName,
C.szNombre StudentName, C.szApellidos
StudentSurName,
B.szNombre ActivityName, D.szNombre
ActivityTypeName,
A.dblNota, B.dblPorcentaje * 100.0 PORCENTAJE,
A.dblNota * B.dblPorcentaje NOTA,
IT.NOTADEF
FROM ((((((Notas A INNER JOIN
ActividadesEv B ON A.idActividadEv =
B.idActividadEv) INNER JOIN
Usuarios C ON A.idUsuario = C.idUsuario)
INNER JOIN
TipoActividades D ON B.idTipoActividad =
D.idTipoActividad) INNER JOIN
GruposCursos E ON B.idGrupoCurso =
E.idGrupoCurso) INNER JOIN
Usuarios F ON E.idDocente = F.idUsuario)
INNER JOIN
(SELECT A.idUsuario, SUM(A.dblNota)
SUMNOTA,
SUM(B.dblPorcentaje) SUMPCTE,
SUM(A.dblNota * B.dblPorcentaje) NOTADEF
FROM ((Notas A INNER JOIN
ActividadesEv B ON A.idActividadEv
= B.idActividadEv) INNER JOIN
GruposCursos E ON B.idGrupoCurso =
E.idGrupoCurso)
WHERE E.idGrupo = 11 AND E.idCurso = 10
GROUP BY A.idUsuario HAVING
SUM(B.dblPorcentaje) = 1
ORDER BY A.idUsuario )
IT ON A.idUsuario = IT.idUsuario)
WHERE E.idGrupo = 11 AND E.idCurso = 10 ORDER BY
C.szNombre, C.szApellidos, B.szNombre
The derived table is with this query
SELECT A.idUsuario, SUM(A.dblNota) SUMNOTA,
SUM(B.dblPorcentaje) SUMPCTE,
SUM(A.dblNota * B.dblPorcentaje) NOTADEF
FROM ((Notas A INNER JOIN
ActividadesEv B ON A.idActividadEv
= B.idActividadEv) INNER JOIN
GruposCursos E ON B.idGrupoCurso =
E.idGrupoCurso)
WHERE E.idGrupo = 11 AND E.idCurso = 10
GROUP BY A.idUsuario HAVING
SUM(B.dblPorcentaje) = 1
ORDER BY A.idUsuario
Someone hinted to use views, but how can I use a view
with parameterized WHERE. Question is, does anybody
know what other path could I use.
Carlos Adolfo Ortiz Q
carlosaortiz@...
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
As I have come across with this query in one of my
applications which I have ported recently from
Microsoft Access to FB (1.5.2, which does not support
Derived tables)
SELECT A.idUsuario, F.szNombre TutorName,
F.szApellidos TutorSurName,
C.szNombre StudentName, C.szApellidos
StudentSurName,
B.szNombre ActivityName, D.szNombre
ActivityTypeName,
A.dblNota, B.dblPorcentaje * 100.0 PORCENTAJE,
A.dblNota * B.dblPorcentaje NOTA,
IT.NOTADEF
FROM ((((((Notas A INNER JOIN
ActividadesEv B ON A.idActividadEv =
B.idActividadEv) INNER JOIN
Usuarios C ON A.idUsuario = C.idUsuario)
INNER JOIN
TipoActividades D ON B.idTipoActividad =
D.idTipoActividad) INNER JOIN
GruposCursos E ON B.idGrupoCurso =
E.idGrupoCurso) INNER JOIN
Usuarios F ON E.idDocente = F.idUsuario)
INNER JOIN
(SELECT A.idUsuario, SUM(A.dblNota)
SUMNOTA,
SUM(B.dblPorcentaje) SUMPCTE,
SUM(A.dblNota * B.dblPorcentaje) NOTADEF
FROM ((Notas A INNER JOIN
ActividadesEv B ON A.idActividadEv
= B.idActividadEv) INNER JOIN
GruposCursos E ON B.idGrupoCurso =
E.idGrupoCurso)
WHERE E.idGrupo = 11 AND E.idCurso = 10
GROUP BY A.idUsuario HAVING
SUM(B.dblPorcentaje) = 1
ORDER BY A.idUsuario )
IT ON A.idUsuario = IT.idUsuario)
WHERE E.idGrupo = 11 AND E.idCurso = 10 ORDER BY
C.szNombre, C.szApellidos, B.szNombre
The derived table is with this query
SELECT A.idUsuario, SUM(A.dblNota) SUMNOTA,
SUM(B.dblPorcentaje) SUMPCTE,
SUM(A.dblNota * B.dblPorcentaje) NOTADEF
FROM ((Notas A INNER JOIN
ActividadesEv B ON A.idActividadEv
= B.idActividadEv) INNER JOIN
GruposCursos E ON B.idGrupoCurso =
E.idGrupoCurso)
WHERE E.idGrupo = 11 AND E.idCurso = 10
GROUP BY A.idUsuario HAVING
SUM(B.dblPorcentaje) = 1
ORDER BY A.idUsuario
Someone hinted to use views, but how can I use a view
with parameterized WHERE. Question is, does anybody
know what other path could I use.
Carlos Adolfo Ortiz Q
carlosaortiz@...
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com