I am trying to develop a sql query that will return a list of serial numbers. The table sets that whenever the serial number reaches the step, the date and time are entered. At the end of this step, another date and time is entered. I want to develop a query that will give me a list of serial numbers that went into this step, but did not go out of this step. They can be entered several times, so I am only looking for serial numbers that do not have outputs after and enter.
Example (for convenience, call the table "Table 1")
1. Serial | Step | Date
2. 1 | enter | 10/1
3. 1 | exit | 10/2
4. 1 | enter | 10/4
5. 2 | enter | 10/4
6. 3 | enter | 10/5
7. 3 | exit | 10/6
In the above table, you need to get serial numbers 1 and 2, but 3 should not be.
Can this be done in a subscription request with subqueries?
user61557
source
share