By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

problem with a querry

P: 40
Hello,
TRAININGS(ID_TRAINING, TRAINING_NAME)
HOSTED_TRAININGS(ID_HOSTED_TRAINING, ID_TRAINING, DAYS)
EMPLOYEES_ON_TRAININGS(ID_HOSTED_TRAINING)

What I want to do is a querry with sum of days and number of employees for each training

Tried something like that but it returns error "ID_HOSTED_TRAINING is not a part of aggregate function" or something like that:/
Expand|Select|Wrap|Line Numbers
  1. SELECT s.TRAINING_NAME AS Szkolenia, Sum(ps.DAYS), (SELECT COUNT(*) FROM EMPLOYEES_ON_TRAININGS as pns WHERE pns.ID_HOSTED_TRAINING = ps.ID_HOSTED_TRAINING)
  2. FROM TRAININGS AS s, HOSTED_TRAININGS AS ps
  3. WHERE (s.ID_TRAINING = ps.ID_TRAINING)
  4. GROUP BY s.TRAINING_NAME
  5. ORDER BY s.TRAINING_NAME;
I also tried to write COUNT function without SELECT statemant but then it counts days wrong :/
Any ideas?
Aug 9 '07 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,392
Use a join instead of a Where.
Aug 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.