Thread View: pl.comp.bazy-danych
1 messages
1 total messages
Started by Cezary Grądys
Sun, 17 Dec 2017 19:20
Postgres - warto podawać nazwy kolumn wynikowych
Author: Cezary Grądys
Date: Sun, 17 Dec 2017 19:20
Date: Sun, 17 Dec 2017 19:20
39 lines
1790 bytes
1790 bytes
Trochę mnie postgres dziś zaskoczył, podobne zapytanie i kolumna w
wyniku nazywa się inaczej (raz id raz case):
test=# select id, case id WHEN 1 THEN 'jeden'
WHEN 2 THEN 'dwa'
ELSE id::text
END FROM test;
id | id
----+-------
5 | 5
14 | 14
1 | jeden
2 | dwa
16 | 16
(5 rows)
test=# select id, CASE id WHEN 1 THEN 'jeden'
WHEN 2 THEN 'dwa'
WHEN 14 THEN 'czternaście'
WHEN 16 THEN 'szesnaście'
end
from test;
id | case
----+-------------
5 |
14 | czternaście
1 | jeden
2 | dwa
16 | szesnaście
(5 rows)
--
Cezary Grądys <czarekgr@wa.onet.pl>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads