3

学生の受験票も含めて20台ほど持っています。私は自分の質問を理解しようとしました(学生ID = sID、つまりスコア1:s1):StudentTables:(student reg.data)

sID   name   surname   regDate     photo           ........
891   Mike   Jackson   01.01.2013  82342984.png    ....

TableA : (生徒の得点)

sID   exam    s1    s2    s3    s4
891   6       0     0     0     20  > student 891 attended exam 6
891   10      30    80    100   75  > student 891 attended exam 10 

(カウント = 2)

TableB : (生徒のドキュメント、つまり: ドキュメント 1 : d1)

sID   d1      d2     d3     d4     d5     d6
891   true    false  true   true   true   true 

(カウント = 1)

TableC : (学生メッセージ)

mID   from    to    subject    message
1     10      891   any sub.   any message... > student 891 received messages (look "to")
1     10      891   mes2       other message... 
1     29      891   mes3       another message...

(カウント = 3)

TableD : (学生の支払い)

sID   pID    amount    date   details   

(このテーブルには生徒のレコードはありません。カウント = 0)

.....そして上記のような同様のテーブル。

以下のような結果が欲しい:

sID   name   surname   scoreCount   docCount   messageCount   paymentCount .....
891   Mike   Jackson   2            1          3              0            ...
892   Susan  Button    0            3          10             0            ...
893   Ahmad  Malisi    1            0          5              2            ...
894   any    any       4            1          0              0            ...
...
..
4

2 に答える 2

2

Have you tried this

Select sid,name,surname,
       (Select count(*) From student_scores Where Sid = S.Sid ) as scoreCount ,
       (Select count(*) From student_documents Where Sid = S.Sid ) as docCount ,
       (Select count(*) From student_messages Where to= S.Sid ) as messageCount  ,
       (Select count(*) From student_payments Where Sid = S.Sid ) as paymentCount ,
        .
        .
        .
From StudentsTables S
Where Sid=891
于 2014-03-14T06:59:36.827 に答える