1
SELECT Rating, SUM(Poids) 
FROM Test
WHERE Portefeuille = 'NameTest' AND LaDate = #20/10/2021# 
GROUP BY Rating 
ORDER BY CASE WHEN Rating = 'AAA' THEN 1 
              WHEN Rating = 'AA+' THEN 2 
              WHEN Rating = 'AA' THEN 3 
              WHEN Rating = 'A+' THEN 4 
              WHEN Rating = 'A' THEN 5 
              WHEN Rating = 'A-' THEN 6 
              ELSE 7   

Why the above SQL String throw an error :

Run-time error รจ-2147467259 (80004005)': Unrecognized keyword WHEN. 
TourEiffel
  • 4,034
  • 2
  • 16
  • 45
  • If you check the online manual for Access you'll learn that it doesn't have CASE expressions. This question and answer should help you... https://stackoverflow.com/questions/15774078/what-is-the-equivalent-of-select-case-in-access-sql โ€“ MatBailie Oct 20 '21 at 13:45
  • @MatBailie So this mean that `ORDER BY SWITCH()` Will allow me to do a custom order ? โ€“ TourEiffel Oct 20 '21 at 13:48
  • 2
    Why ask a question you can test and answer for yourself? No matter what someone tells you, you're going to have to test it yourself anyway. (Yes, use switch.) โ€“ MatBailie Oct 20 '21 at 13:58

0 Answers0