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 –
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%';