V4MD aggregation in subquery

info at vallemediatime.com info at vallemediatime.com
Sun Dec 4 09:47:54 CST 2005


Hi all,
I need to get a record set like this example by SQL way, I read that it is 
necessary a subquery... right?

T1   Registration  (Reg)
Fld  Reg_Code  |  Reg_Course_Ref  |  Reg_Student_Ref
R1      1                 1000                       10
R2      1                 1000                       11
R3      2                 1001                       12

T2   Courses
Fld  Course_ID  |  Course_Name |
R1   1000                Math
R2   1001                Music

 I want to get a count of all courses that have a Reg_Code = 1
eg
Fld   Course_Name | Reg_Code_Count
R1      Math                      2
R2      Music                    1


My wrong tentative is this:
query = "SELECT Course_Name, \
(SELECT COUNT(Reg_Code) \
FROM Registration  WHERE Reg_Code = 1) \
FROM Corsi \
WHERE Corsi_ID = Reg_Corsi_Ref  "

Can somebody help me?
Thanks
Paolo 



More information about the Valentina-beta mailing list