×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

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.