1-- use postgress case
2
3SELECT name, continent, indep_year,
4 CASE WHEN indep_year < 1900 THEN 'before 1900'
5 WHEN indep_year <= 1930 THEN 'between 1900 and 1930'
6 ELSE 'after 1930' END
7 AS indep_year_group
8FROM countries
9ORDER BY indep_year_group;
1
2
3
4
5 DO $$
6DECLARE
7 a integer := 10;
8 b integer := 20;
9BEGIN
10 IF a > b THEN
11 RAISE NOTICE 'a is greater than b';
12 END IF;
13
14 IF a < b THEN
15 RAISE NOTICE 'a is less than b';
16 END IF;
17
18 IF a = b THEN
19 RAISE NOTICE 'a is equal to b';
20 END IF;
21END $$;
22