Reputation: 11
I am having a Table contain two columns named Time_stamp and PWPH_Pmp_2_FBSts and table name is per_hour_log The Sample of A Screen Shot I embedded
for the reference.The Query Which I Wrote is as follows
SELECT MAX(time_stamp) AS recent_datetime
FROM per_hour_log
WHERE PWPH_Pmp_2_FBSts = 2
AND time_stamp BETWEEN '2023-02-01 01:00:00' AND '2023-02-05 20:00:00'
AND EXISTS (
SELECT 1 FROM per_hour_log
WHERE PWPH_Pmp_2_FBSts = 1
AND time_stamp BETWEEN '2023-02-01 01:00:00' AND '2023-02-05 20:00:00'
)
The OutPut I am Expecting is
03-02-2023 05:00:00
02-02-2023 13:00:00
Upvotes: 0
Views: 25