×

Loading...
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!

How to use CASE WHEN in Access?

In SQL server:
SELECT Category =
CASE type
WHEN 'popular_comp' THEN 'Popular Computing'
WHEN 'mod_cook' THEN 'Modern Cooking'
WHEN 'business' THEN 'Business'
WHEN 'psychology' THEN 'Psychology'
WHEN 'trad_cook' THEN 'Traditional Cooking'
ELSE 'Not yet categorized'
END,
CAST(title AS varchar(25)) AS 'Shortened Title',
price AS Price
FROM titles
WHERE price IS NOT NULL
ORDER BY type, price
COMPUTE AVG(price) BY type
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / How to use CASE WHEN in Access?
    In SQL server:
    SELECT Category =
    CASE type
    WHEN 'popular_comp' THEN 'Popular Computing'
    WHEN 'mod_cook' THEN 'Modern Cooking'
    WHEN 'business' THEN 'Business'
    WHEN 'psychology' THEN 'Psychology'
    WHEN 'trad_cook' THEN 'Traditional Cooking'
    ELSE 'Not yet categorized'
    END,
    CAST(title AS varchar(25)) AS 'Shortened Title',
    price AS Price
    FROM titles
    WHERE price IS NOT NULL
    ORDER BY type, price
    COMPUTE AVG(price) BY type
    • I am not sure Access can use CASE.
      • What function I can use in Access to achive the same result using Case When function in sql server?
        • Switch Function?
        • I am not familair with Access, up for you.
    • Use Select Case Statement. The statement can only be used in the form as VBA code, not in SQL statement. In SQL statement, use IIF() instead.
      • Thanks! IIF works.