Subject | Sql queries |
---|---|
Author | Datatal AB - Gauffin, Jonas |
Post date | 2003-09-14T15:03:03Z |
1. I got a table called booking with these fields:
bookingid
flightnr
price
depart_date
I want to get each flight where sum of price is larger than all flighs average sum of price. Please help.
I guess that I gotto do a subselect?
2. I got two tables called service and technician with these fields:
service
=====
tech_id
service_type
amount_hours
technician
=======
tech_id
firstname
lastname
I want to show wich technician that have made most services of a specific type. If two technicans have made the same amount of services of a specific type both should be displayed.
i tried something like this:
select service_type, firstname, lastname, count(service_type)
from service s
inner join technician t on (s.tech_id=t.tech_id)
group by service_type, firstname, lastname
Since the group is on all 3 fields not only the best tech is shown
[Non-text portions of this message have been removed]
bookingid
flightnr
price
depart_date
I want to get each flight where sum of price is larger than all flighs average sum of price. Please help.
I guess that I gotto do a subselect?
2. I got two tables called service and technician with these fields:
service
=====
tech_id
service_type
amount_hours
technician
=======
tech_id
firstname
lastname
I want to show wich technician that have made most services of a specific type. If two technicans have made the same amount of services of a specific type both should be displayed.
i tried something like this:
select service_type, firstname, lastname, count(service_type)
from service s
inner join technician t on (s.tech_id=t.tech_id)
group by service_type, firstname, lastname
Since the group is on all 3 fields not only the best tech is shown
[Non-text portions of this message have been removed]