Sum of courses booked, SQL -


working on query calculate total sum of current courses booked, cost of course shown in course table, current courses booked shown in booking table how sum of total price current courses booked?

course table:

   courseid             cost      `````````````````````````````      96                 300      32                 400      25                 500      62                 600 

booking table:

bookidid          courseid  `````````````````````````````  1                 96  2                 96  3                 96  4                 62 

the end result should be

courseidtot        total --------------------- 96               900 62               600 

will need join not sure how * total of courses booked cost on different course ids. thanks!

try joining 2 tables like:

select c.courseid courseidtot, sum(cost) total course c inner join booking b on   c.courseid = b.courseid group c.courseid 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -