0

I got a problem with my request.

I want to compare 2 dates, and if the number of days is inferior to 2, i want to display nothing. But if it's over, I want to display the days. I got my request but it failed when I try to compare the DATEDIFF to 2.

SQL> SELECT noLivraison, noCommande, noArticle, dateCommande, quantite, dateLivraison, quantiteLivree, 
CASE dateCommande
WHEN DATEDIFF(day, dateLivraison, dateCommande) < 2 THEN null
ELSE DATEDIFF(day, dateLivraison, dateCommande)
END nombreJoursEcoules
FROM Commande
NATURAL JOIN LigneCommande
NATURAL JOIN Livraison      
NATURAL JOIN DetailLivraison  2    3    4    5    6    7    8    9  
 10  /
WHEN DATEDIFF(day, dateLivraison, dateCommande) < 2 THEN null
                                                *
ERROR at line 3:
ORA-00905: missing keyword

I don't know how to fix it, I put more parenthesis but it didn't works.

Ty for reading.

bl4ckb0ne
  • 1,097
  • 2
  • 15
  • 30

1 Answers1

0

You can try the below code , may be it will solve your problem

         select col1,col2,case when DATEDIFF(dd, dateLivraison, dateCommande)

         >= 2 then 'days' else null end as 'datefield', DATEDIFF(dd, dateLivraison, 

         dateCommande) as 'days' from tablename

Thanks