Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi, I want to pull data from a table in a database with this statement.
It works, but returns only the records with the first datetime in the 'IN' clause (08/27/2024 03:34:05).
For information: the list with datetimes is generated dynamically with data from another table.
I am sure that there are records in the table that should be returned.
So why it stucks to the first datetime in the list and ignores the others?
Select DateTime, Tagname, Value FROM table WHERE TagName='P124' OR Tagname='P132' AND DateTime IN ('08/27/2024 03:34:05', '08/27/2024 02:07:46', '08/27/2024 03:30:05')
Solved! Go to Solution.
Use ISO-8601 formatting, always.
You need to protect the OR part from the AND part.
Select DateTime, Tagname, Value FROM table WHERE TagName IN ('P124' ,'P132') AND DateTime IN ('08/27/2024 03:34:05', '08/27/2024 02:07:46', '08/27/2024 03:30:05')
Use ISO-8601 formatting, always.
You need to protect the OR part from the AND part.
Select DateTime, Tagname, Value FROM table WHERE TagName IN ('P124' ,'P132') AND DateTime IN ('08/27/2024 03:34:05', '08/27/2024 02:07:46', '08/27/2024 03:30:05')
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |