Skip to content

Commit

Permalink
Update and rename 2.6.sql to 2.6_FINAL.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannidis authored May 13, 2018
1 parent 6f6e7b0 commit ca691ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
8 changes: 0 additions & 8 deletions 2.6.sql

This file was deleted.

24 changes: 24 additions & 0 deletions 2.6_FINAL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SELECT
car_models.title,
car_models.code,
car_warehouse.plate,
customers.first_name,
customers.last_name,
COUNT(car_models.code) as service_count
FROM
service_history
INNER JOIN car_warehouse ON service_history.car_id = car_warehouse.id
INNER JOIN customers ON car_warehouse.owner_id = customers.id
INNER JOIN car_models ON car_warehouse.model_id = car_models.id
WHERE
service_history.start_date <= date_trunc('year', now()) - interval '1 year'
OR
service_history.end_date <= date_trunc('year', now()) - interval '1 year'
GROUP BY
car_models.id,
car_warehouse.plate,
customers.id
HAVING
COUNT(car_models.code) > 1
ORDER BY
service_count DESC

0 comments on commit ca691ee

Please sign in to comment.