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

Why the output is blank when added a name in Where clause with AND?

The below query is running fine with good output –

SELECT  RadioFinalizedBy, ProcedureType, DATEDIFF(HOUR, ScanCompleteDate,RadioFinalisedDate) As 'Date Diff', 
        ScanCompleteDate, RadioFinalisedDate
FROM    VW_RisOrderTable
WHERE   YEAR(ScanCompleteDate) = 2023
AND     MONTH(ScanCompleteDate) = 03
AND     DATEDIFF(HOUR, ScanCompleteDate,RadioFinalisedDate) > 24;

But as soon as I add one more ‘AND’ to it, the query runs but the output is blank.

Adding one more AND –

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

SELECT  RadioFinalizedBy, ProcedureType, DATEDIFF(HOUR, ScanCompleteDate,RadioFinalisedDate) As 'Date Diff', 
        ScanCompleteDate, RadioFinalisedDate
FROM    VW_RisOrderTable
WHERE   YEAR(ScanCompleteDate) = 2023
AND     MONTH(ScanCompleteDate) = 03
AND     DATEDIFF(HOUR, ScanCompleteDate,RadioFinalisedDate) > 24
AND     RadioFinalizedBy = 'Yasser Mahfouz';

There are records with the above condition but still, the output is blank.

Even when I run the below simple query, the output is still blank.

SELECT * FROM VW_RisOrderTable WHERE RadioFinalizedBy = 'Yasser Mahfouz';

I am using SQL SERVER. Please help.

>Solution :

SELECT * FROM VW_RisOrderTable WHERE RadioFinalizedBy = 'Yasser Mahfouz';

If above query is returning no rows then it’s there is no rows with the given condition. First check the spelling again carefully. If it’s same then you might have extra character at the end or beginning try below query to rule out this:

SELECT * FROM VW_RisOrderTable WHERE RadioFinalizedBy like '%Yasser%Mahfouz%';
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