Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
venkatch786
Starting Member
8 Posts |
Posted - 2010-10-07 : 08:45:58
|
| I have a table having columns district_id and school_id tot_schools.I have data for district_id and school_id.for tot_schools NULLnow i want to update tot_schools columns with no.of schools in wach districtI get tha data like this way but I cant update for tot_schools column SELECT DISTRICT_ID ,COUNT(SCHOOL_ID) FROM TABLE1GROUP BY DISTRICT_IDThanks in advance...venkateswarlu. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-07 : 14:10:02
|
| Try this:Update Table1 Set tot_schools = ST.RecCountFrom Table1 T inner join(SELECT DISTRICT_ID ,COUNT(SCHOOL_ID) RecCount FROM TABLE1GROUP BY DISTRICT_ID) as STOn T.DISTRICT_ID = ST.DISTRICT_IDRegards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
|
|
|