`
butterluo
  • 浏览: 54131 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论

sql---example of the using of "case when"

    博客分类:
  • sql
阅读更多
/*tested in oracle*/
/* you can use select statment in then clause*/
SELECT CASE bh.zajlx
          WHEN '2'
             THEN (SELECT qt1.sfdb
                     FROM t03_qtajxx qt1
                    WHERE qt1.ajbh = bh.ajbh)
          WHEN '1'
             THEN (SELECT cta1.sfdb
                     FROM t03_ctais_ajxx cta1
                    WHERE cta1.ajbh = bh.ajbh)
          WHEN '3'
             THEN (SELECT cta1.sfdb
                     FROM t03_ctais_ajxx cta1
                    WHERE cta1.ajbh = bh.ajbh)
          ELSE 'X'
       END
  FROM t03_ajbh bh
WHERE bh.ajbh = '00200700003'

/*you can use in keyword in when clause*/
select t6.nsrdzdah, t6.ajszjg_j_dm, t6.jczt_dm,
        case
            when t6.jczt_dm  in (01,02,10,  20,21,22,30,  40,41,42,43,44,45,50,  60,70)
                then 'Y'
            else 'N'
         end aa
    from JC_AJXX t6 order by t6.nsrdzdah
分享到:
评论

相关推荐

    微软内部资料-SQL性能优化5

    The IAM allows SQL Server to do efficient prefetching of the table’s extents, but every row still must be examined. General Index Structure All SQL Server Indexes Are Organized As B-Trees ...

    微软内部资料-SQL性能优化2

    The following definitions will help you understand how SQL Server interacts with the operating system when allocating and using memory. Virtual Address Space A set of memory addresses that are mapped...

    SQL Assistant v5.0

    type and standalone code formatters support new formatting options allowing simultaneous use of different cases for keywords and for system functions, for example uppercasing keywords and using mixed ...

    Virtualizing SQL Server with VMware_English

    The book "Virtualizing SQL Server with VMware" provides an in-depth exploration of best practices and techniques for virtualizing SQL Server using VMware solutions. Here, we delve into key knowledge ...

    php.ini-development

    The syntax of the file is extremely simple. Whitespace and lines ; beginning with a semicolon are silently ignored (as you probably guessed). ; Section headers (e.g. [Foo]) are also silently ignored,...

    Java for Programmers

    PRACTICAL, EXAMPLE-RICH COVERAGE OF: * Classes, Objects, Encapsulation, Inheritance, Polymorphism, Interfaces, Nested Classes * Integrated OOP Case Studies: Time, GradeBook, Employee * Industrial-...

    Delphi7.1 Update

    * When using RefreshRecord on a Memo or Blobfield and the field has been modified by another user, the blobsize of that field does not change if it is less than before (Quality Central 4676).* ...

    BobBuilder_app

    Theoretically a b+tree is O(N log k N) or log base k of N, now for the typical values of k which are above 200 for example the b+tree should outperform any binary tree because it will use less ...

    Programming Microsoft LINQ in Microsoft.NET Framework 4

    Along the way you’ll enjoy the Deitels’ classic treatment of object-oriented programming and the OOD/UML® ATM case study, including a complete C# implementation. When you’re finished, you’ll be ...

    C# 2010 for Programmers 4ed part1

    Along the way you’ll enjoy the Deitels’ classic treatment of object-oriented programming and the OOD/UML® ATM case study, including a complete C# implementation. When you’re finished, you’ll be ...

    SQL语句大全

    根据提供的文件信息,我们可以归纳出一系列重要的SQL语句及其用途,这些内容对于学习数据库管理和查询非常重要。接下来将详细解释每一个提到的关键SQL语句,并提供简要示例。 ### SQL语句大全 #### 1. SELECT ...

    VB编程资源大全(英文源码 数据库)

    Its then backed up just in case, compressed and then the original is deleted before the new compacted version is moved back in place of the original.<END><br>37,dbinfo.zip We've written this mainly...

    Sql for mysql

    1.5 The History of SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 1.6 From Monolithic via Client/Server to the Internet . . . . . . . . . . 18 1.7 Standardization of SQL . ...

    SQL server 实用资料

    - 示例:`UPDATE employee SET e_wage = CASE WHEN job_level = '1' THEN e_wage * 1.08 WHEN job_level = '2' THEN e_wage * 1.07 WHEN job_level = '3' THEN e_wage * 1.06 ELSE e_wage * 1.05 END;` 3. **WHILE ...

    freeradius切换为ipv6

    # In that case, the smallest possible network will be used # as the "best match" for the client. # Clients can also be defined dynamically at runtime, based # on any criteria. e.g. SQL lookups, ...

Global site tag (gtag.js) - Google Analytics