Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
I have a union select statement that I can't figure out where the problem is. I want to count all the students who haven't completed a course and have no dropdate unless the dropdate is 1 month or more after the startdate. So I combined my select statements with a union select. The problem is I get a syntax error.
Here is my select statement:
select courseprogram.programid, studentcourse.courseid, &groupchoice as mygroup,;
instructor.ifname, count(studentcourse.instructorid) as numstud, studentcourse.instructorid,;
nvl(program.program, " ") as program;
from studentcourse left join instructor on studentcourse.instructorid = instructor.instructorid,;
courseprogram left join program on courseprogram.programid = program.programid;
where courseprogram.courseid = studentcourse.courseid;
and studentcourse.startdate >= {12/01/1999};
and studentcourse.dropdate != {};
and month(studentcourse.dropdate) - month(studentcourse.startdate) >= 1;
or year(studentcourse.dropdate) - year(studentcourse.startdate) >= 1;
and studentcourse.iscomplete = .F.;
union select courseprogram.programid, studentcourse.courseid, &groupchoice as mygroup,;
instructor.ifname, count(studentcourse.instructorid) as numstud, studentcourse.instructorid,;
nvl(program.program, " ") as program;
from studentcourse left join instructor on studentcourse.instructorid = instructor.instructorid,;
courseprogram left join program on courseprogram.programid = program.programid;
where courseprogram.courseid = studentcourse.courseid;
and studentcourse.startdate >= {12/01/1999};
and studentcourse.dropdate == {};
and studentcourse.iscomplete = .F.;
into cursor clbudgetnew;
group by mygroup, studentcourse.courseid, studentcourse.instructorid
Where could the syntax error be? Just need some help getting this to work.
TIA,
Tyler
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement