Skip to content
Advertisement

How can i count project status by change/update made

I want to count status change by id from to

I have a mysql status table which has a name with pre implementation, implementation and operations states.

  • a project contains project id, name, start date fields.
  • both status and projects have a many to many relationship called project_status table contains project_id, status_id, date_of_progress.

so i want to count all projects within this month who has update/change their status_id

  1. from pre-implementation to implementations
  2. from implementations to operations
  3. from pre-implementation to operations

Desire Output

Advertisement

Answer

I think the key is find what is the last status for each project on each month:

SQL DEMO

OUTPUT

Now using a correlated query you can found out the last status before the current month:

OUTPUT

Now just do some conditional counts

OUTPUT

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement