lundi 28 décembre 2015

How to find number of records and update another table?

I have a table (degrees)like this :

dID        dmID    dlID    d11  

540        1         1      44                  
541        1         2      55                  
542        1         3      66                              
545        2         1      56                  
546        2         2      76                  
547        2         3      87                                  
550        3         1      55                  
551        3         2      78                  
552        3         3      87                                  
555        4         1      22                  
556        4         2      22                  
557        4         3      78      

I want to find how many d11<50 for every dmID SO I use:

SELECT   COUNT(*)  FROM degrees  
 WHERE degrees.[d11]<50
  GROUP BY degrees.dmID

This the results:

COUNT(*)

   1
   2

My Question: How Can I update These values to another table column called midTable.Result where midTable.[mid] = degrees.[dmID] ?

This is midTable Structure:

mID    Result

1        null
2        null
3        null

Aucun commentaire:

Enregistrer un commentaire