Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Need assistance with an Oracle SQL query

I have the following query and I am wondering what is wrong with it. It is not filtering on the date range I have chosen. I have tried reordering my WHERE clause, it doesn’t seem to work.

SELECT UNIT_NUMBER, ORG_CREATED_ACTIVE_DATE, ORG_TYPE
FROM TABLE_NAME
WHERE ORG_TYPE = 'Ward'
OR ORG_TYPE = 'Branch'
OR ORG_TYPE = 'Stake'
OR ORG_TYPE = 'District'
AND ORG_CREATED_ACTIVE_DATE BETWEEN '02-JUL-23' AND '18-DEC-23';

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You are using both AND and OR inside the WHERE.

SELECT UNIT_NUMBER, ORG_CREATED_ACTIVE_DATE, ORG_TYPE
FROM TABLE_NAME
WHERE (ORG_TYPE = 'Ward'
       OR ORG_TYPE = 'Branch'
       OR ORG_TYPE = 'Stake'
       OR ORG_TYPE = 'District')
AND ORG_CREATED_ACTIVE_DATE BETWEEN '02-JUL-23' AND '18-DEC-23';
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading