I have a rather complex SQL query that I am looking for a little help with.
I have two tables: a history table and a details table.
The history table contains the following columns.
Event Date(ev_date) Event Code(ev_code) Machine ID(mc_id)
The Details table contains the following columns:
Machine ID(mc_id), Location ID(lo_id) Machine Name(mc_name)
I need a query that returns the count of the number of events from the history table between a given date range of a given group of machines given by Location ID.
So, kinda in sudo code:
SELECT COUNT(*) FROM history WHERE ev_date (BETWEEN start_date AND end_date) AND ev_code = 1 AND ????
(mc_id must have certain lo_id from details table).
Does this make sense?