
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
"David Portas" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Your table design has some problems: Non-normalised repeating group of > Grades; No natural primary key; Too many NULLable columns (if every column > can be NULL then why would you have a row in the table anyway!). This query > would be a lot simpler if you fixed these things. > > SELECT county, YEAR(dateentered) AS year_entered, > SUM( > COALESCE(grade1,0)+ > COALESCE(grade2,0)+ > COALESCE(grade3,0)+ > COALESCE(grade4,0)+ > COALESCE(grade5,0)+ > COALESCE(grade6,0)+ > COALESCE(grade7,0)+ > COALESCE(grade8,0)+ > COALESCE(grade9,0)+ > COALESCE(grade10,0)+ > COALESCE(grade11,0)+ > COALESCE(grade12,0)+ > COALESCE(grade13,0)+ > COALESCE(grade14,0)+ > COALESCE(grade15,0)+ > COALESCE(grade16,0)+ > COALESCE(grade17,0)) > AS tot_students > FROM EdSales > GROUP BY county, YEAR(dateentered) Well, I am a newbie at this sort of a thing. So, any pointers to useful info on the diffiencies you mention are appreciated.
| <-- __Chronological__ --> | <-- __Thread__ --> |