File: 100_select_case.sql

package info (click to toggle)
sqlfmt 0.29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,580 kB
  • sloc: python: 10,007; sql: 5,626; makefile: 39
file content (47 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
select
    my_first_field,
    my_second_field as an_alias,
    case
        when another_field = some_other_value
        then some_really_long_value
    end as my_case_statement,
    case
        when caser = 'my_literal'
            then some_really_really_long_value_to_wrap_this_next_line
        else
            42
    end,
    CASE
        when (my_field) then end_field
    END::numeric(10, 2) as casted_case,
    (case when ending then false end)+(case when 2 then true end)::varchar(10),
    another_field,
    case when true then 10 end+4,
    case-- a comment with no spaces
        when something_long_that_keeps_this_from_wrapping
        then something_else_long_long_long
        else another_super_long_field_name
    end
from some_table
)))))__SQLFMT_OUTPUT__(((((
select
    my_first_field,
    my_second_field as an_alias,
    case
        when another_field = some_other_value then some_really_long_value
    end as my_case_statement,
    case
        when caser = 'my_literal'
        then some_really_really_long_value_to_wrap_this_next_line
        else 42
    end,
    case when (my_field) then end_field end::numeric(10, 2) as casted_case,
    (case when ending then false end) + (case when 2 then true end)::varchar(10),
    another_field,
    case when true then 10 end + 4,
    case  -- a comment with no spaces
        when something_long_that_keeps_this_from_wrapping
        then something_else_long_long_long
        else another_super_long_field_name
    end
from some_table