-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsample_code.snowql
105 lines (88 loc) · 2.08 KB
/
sample_code.snowql
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* A test script
*
* TODO A thing
*/
// USE DATABASE "DEV";
-- NOTE Comment here
CREATE TABLE pkmn.top_fire -- XXX
SELECT
cast(number AS INT),
name,
type_1,
type_2,
'\* \n SOMETHING' AS test_1,
max(abs(attack)) AS attack,
try_to_binary(is_legendary) AS is_legendary,
IFF(name IS NULL, 1, 0)
case
when (attack + defense) > (special_attack + special_defense)
then 'physical'
else 'special'
end as strategy
FROM
pkmn.stats
WHERE
type_1 = 'fire'
OR type_2 <> 'water'
or number in (150, 300, 450)
GROUP BY
number,
name,
type_1,
type_2
HAVING
attack between -200.0 AND 100.10;
SELECT
TOP 4
FROM
"DEV"."ZENDESK"."TICKETS"
WHERE
datepartition BETWEEN '2020-09-01' AND current_date()
ORDER BY
ticket_id DESC;
ALTER TASK "DEV"."ZENDESK"."TICKETS" SUSPEND;
create or replace table monthly_sales(empid int, amount int, month text)
as select * from values
(1, 10000, 'JAN'),
(1, 400, 'JAN'),
(2, 4500, 'JAN'),
(2, 35000, 'JAN'),
(1, 5000, 'FEB'),
(1, 3000, 'FEB'),
(2, 200, 'FEB'),
(2, 90500, 'FEB'),
(1, 6000, 'MAR'),
(1, 5000, 'MAR'),
(2, 2500, 'MAR'),
(2, 9500, 'MAR'),
(1, 8000, 'APR'),
(1, 10000, 'APR'),
(2, 800, 'APR'),
(2, 4500, 'APR');
select
distinct empid as emp_id,
case
when month = 'JAN' then 'january' else month
end,
"'JAN'" as january,
"'FEB'" as february,
"'MAR'" as march,
"'APR'" as april
from monthly_sales
pivot(bitshiftleft(amount) for month in ('JAN', 'FEB', 'MAR', 'APR')) as p
order by empid desc;
SELECT t.*
FROM my.table as t
LEFT JOIN my.other as o ON t.id = o.id
create table collation_demo (
uncollated_phrase varchar,
utf8_phrase varchar collate 'utf8',
english_phrase varchar collate 'en',
spanish_phrase varchar collate 'sp'
);
insert into collation_demo (uncollated_phrase, utf8_phrase, english_phrase, spanish_phrase)
values ('pinata', 'pinata', 'pinata', 'piñata');
create table if not exists mytable (date timestamp_ntz, id number, content variant) cluster by (date, id);
-- show tables like 'mytable';
SHOW TRANSACTIONS;