Expression after case-statement

Source: Internet
Author: User

The syntax for a case when statement in SQL is as follows

Simple Caseexpression: Caseinput_expression whenWhen_expression ThenResult_expression[. .. n]      [ELSE else_result_expression] ENDsearched Caseexpression: Case      whenBoolean_expression ThenResult_expression[. .. n]      [ELSE else_result_expression] END

Where result_expression is supposed to be an arbitrary and valid expression, the same goes for MSDN. Can use this statement today, want to write a simple SELECT statement behind when, actually error.

Tried for a long time, and later wanted to try without a brace, and then succeeded.

 Caseod. ObjectType when 1  Then(SELECT TOP 1Structurename fromTbl_stationstructureWHEREStructuretype=2)     when 2  Then(SELECT TOP 1Structurename fromTbl_stationstructureWHEREStructureid=od. OBJECTID)END    

Expression after case-statement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.