Page 3 - SQL
P. 3

Shorthand CASE in SELECT                                                                          11

            CASE in a clause ORDER BY                                                                         11

            Using CASE in UPDATE                                                                              12

            CASE use for NULL values ordered last                                                             12

            CASE in ORDER BY clause to sort records by lowest value of 2 columns                              13

        Sample data                                                                                          13

        Query                                                                                                13

        Results                                                                                              14


        Explanation                                                                                          14

        Chapter 6: Clean Code in SQL                                                                         15

          Introduction                                                                                        15

          Examples                                                                                            15

            Formatting and Spelling of Keywords and Names                                                     15

        Table/Column Names                                                                                   15

        Keywords                                                                                             15


          SELECT *                                                                                            15

          Indenting                                                                                           16

          Joins                                                                                               17

        Chapter 7: Comments                                                                                  19

          Examples                                                                                            19

            Single-line comments                                                                              19

            Multi-line comments                                                                               19

        Chapter 8: Common Table Expressions                                                                  20

          Syntax                                                                                              20

          Remarks                                                                                             20

          Examples                                                                                            20

            Temporary query                                                                                   20

            recursively going up in a tree                                                                    21

            generating values                                                                                 21

            recursively enumerating a subtree                                                                 22

            Oracle CONNECT BY functionality with recursive CTEs                                               23
   1   2   3   4   5   6   7   8