I need to be able to select all Userpin that have tr_type 7 only but if there is tr_type 7 and 8 in other row ignore 7 and 8 example:
Userpin TrDate Time1 Tr_type4555 12-02-2020 7:30 74555 12-02-2020 14:30 86985 12-02-2020 7:34 79854 12-02-2020 7:15 78542 12-02-2020 7:16 78542 12-02-2020 14:40 8
Using this data set I am looking for Query To Get that data with userpin that have only tr_type equal 7 in current day and i want the result like that :
Userpin TrDate Time1 Tr_type6985 12-02-2020 7:34 79854 12-02-2020 7:15 7
i used that query to get data in current day
select UserPIN ,TrDate,Time1,Tr_Typefrom mytablewhere UserPIN in (6985,9854,4555,8542,4062,7070,4189,4197)and TrDate=CAST(GETDATE() AS DATE)
This seems like a simple thing to query, but I am finding myself up against a wall. What's the best way to accomplish this in a reasonably efficient way?