zajicek=> \dt List of relations Name | Type | Owner ----------+-------+--------- dept | table | zajicek emp | table | zajicek salgrade | table | zajicek (3 rows) zajicek=> select * from dept zajicek-> ; deptno | dname | loc --------+------------+---------- 10 | ACCOUNTING | NEW YORK 20 | RESEARCH | DALLAS 30 | SALES | CHICAGO 40 | OPERATIONS | BOSTON (4 rows) zajicek=> select * from emp; empno | ename | job | mgr | hiredate | sal | comm | deptno -------+--------+-----------+------+------------+---------+---------+-------- 7839 | KING | PRESIDENT | | 1981-11-17 | 5000.00 | | 10 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | | 30 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 1500.00 | | 10 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | | 20 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | | 30 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | | 20 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | | 20 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | | 20 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | | 20 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | | 10 (14 rows) zajicek=> select * from salgrade; grade | losal | hisal -------+---------+--------- 1 | 700.00 | 1200.00 2 | 1201.00 | 1400.00 3 | 1401.00 | 2000.00 4 | 2001.00 | 3000.00 5 | 3001.00 | 9999.00 (5 rows) zajicek=> select ename as manager from emp where job='manager; zajicek'> ' zajicek-> ; manager --------- (0 rows) zajicek=> select ename as manager from emp where job='MANAGER'; manager --------- BLAKE CLARK JONES (3 rows) zajicek=> select ename as 'ma sefa' from emp where mgr<>null; ERROR: parser: parse error at or near "'" zajicek=> shit zajicek-> select ename||' '||sal from emp; ERROR: parser: parse error at or near "shit" zajicek=> ; zajicek=> select ename||' '||sal from emp; ERROR: Unable to identify an operator '||' for types 'varchar' and 'numeric' You will have to retype this query using an explicit cast zajicek=> select ename,sal from emp; ename | sal --------+--------- KING | 5000.00 BLAKE | 2850.00 CLARK | 1500.00 JONES | 2975.00 MARTIN | 1250.00 ALLEN | 1600.00 TURNER | 1500.00 JAMES | 950.00 WARD | 1250.00 FORD | 3000.00 SMITH | 800.00 SCOTT | 3000.00 ADAMS | 1100.00 MILLER | 1300.00 (14 rows) zajicek=> select ename,sal from emp where (deptno=10) and (mgr=7788); ename | sal -------+----- (0 rows) zajicek=> select ename,sal from emp where ((deptno=10) and (mgr=7788)); ename | sal -------+----- (0 rows) zajicek=> select ename,sal from emp where ((deptno=10) and (mgr=7788)) or comm> sal; ename | sal --------+--------- MARTIN | 1250.00 (1 row) zajicek=> select ename,job,sal,hiredate,sal*1.1 as "zvyseny plat" where (job='M zajicek=> select ename,sal from emp where ((deptno=10) and (mgr=7788)) or comm> zajicek=> select ename,job,sal,hiredate,sal*1.1 as "zvyseny plat" where (job='M zajicek=> select ename,job,sal,hiredate,sal*'1.1 as "zvyseny plat" where (job=' zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" where (job= zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" where (job= 'MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') or job ='CLERK' or job='SALESMAN'; ERROR: Attribute 'ename' not found zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" where (job= 'MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') or job zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" fwhere (job ='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') or jo zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" frwhere (jo b='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') or j zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" frowhere (j ob='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') or zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" fromwhere ( job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') or zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from where (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') o zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from ewhere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emwher e (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from empwhe re (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10' zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10 zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from empwhe re (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10' zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emwher e (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from em whe re (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10' zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emwher e (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10') zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from empwhe re (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10' zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10 zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10 ') or job='CLERK' or job='SALESMAN'; ename | job | sal | hiredate | zvyseny plat --------+----------+---------+------------+-------------- BLAKE | MANAGER | 2850.00 | 1981-05-01 | 3135.000 CLARK | MANAGER | 1500.00 | 1981-06-09 | 1650.000 JONES | MANAGER | 2975.00 | 1981-04-02 | 3272.500 MARTIN | SALESMAN | 1250.00 | 1981-09-28 | 1375.000 ALLEN | SALESMAN | 1600.00 | 1981-02-20 | 1760.000 TURNER | SALESMAN | 1500.00 | 1981-09-08 | 1650.000 JAMES | CLERK | 950.00 | 1981-12-03 | 1045.000 WARD | SALESMAN | 1250.00 | 1981-02-22 | 1375.000 SMITH | CLERK | 800.00 | 1980-12-17 | 880.000 ADAMS | CLERK | 1100.00 | 1983-01-12 | 1210.000 MILLER | CLERK | 1300.00 | 1982-01-23 | 1430.000 (11 rows) zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10 ') or ((job='CLERK' or job='SALESMAN') and sal>'2000'); ename | job | sal | hiredate | zvyseny plat -------+---------+---------+------------+-------------- BLAKE | MANAGER | 2850.00 | 1981-05-01 | 3135.000 CLARK | MANAGER | 1500.00 | 1981-06-09 | 1650.000 JONES | MANAGER | 2975.00 | 1981-04-02 | 3272.500 (3 rows) zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10 ') or ((job='CLERK' or job='SALESMAN') and sal<'2000'); ename | job | sal | hiredate | zvyseny plat --------+----------+---------+------------+-------------- BLAKE | MANAGER | 2850.00 | 1981-05-01 | 3135.000 CLARK | MANAGER | 1500.00 | 1981-06-09 | 1650.000 JONES | MANAGER | 2975.00 | 1981-04-02 | 3272.500 MARTIN | SALESMAN | 1250.00 | 1981-09-28 | 1375.000 ALLEN | SALESMAN | 1600.00 | 1981-02-20 | 1760.000 TURNER | SALESMAN | 1500.00 | 1981-09-08 | 1650.000 JAMES | CLERK | 950.00 | 1981-12-03 | 1045.000 WARD | SALESMAN | 1250.00 | 1981-02-22 | 1375.000 SMITH | CLERK | 800.00 | 1980-12-17 | 880.000 ADAMS | CLERK | 1100.00 | 1983-01-12 | 1210.000 MILLER | CLERK | 1300.00 | 1982-01-23 | 1430.000 (11 rows) zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate>'1981-01-01') or (job='MANAGER' and deptno<>'10 ere (job='MANAGER' and hiredate'1981-01-01') or (job='MANAGER' and deptno<>'10' ere (job='MANAGER' and hiredate '1981-01-01') or (job='MANAGER' and deptno<>'10 ere (job='MANAGER' and hiredate l'1981-01-01') or (job='MANAGER' and deptno<>'1 ere (job='MANAGER' and hiredate li'1981-01-01') or (job='MANAGER' and deptno<>' ere (job='MANAGER' and hiredate lik'1981-01-01') or (job='MANAGER' and deptno<> ere (job='MANAGER' and hiredate like'1981-01-01') or (job='MANAGER' and deptno< ere (job='MANAGER' and hiredate like '1981-01-01') or (job='MANAGER' and deptno ere (job='MANAGER' and hiredate like '1981-01-0') or (job='MANAGER' and deptno< ere (job='MANAGER' and hiredate like '1981-01-') or (job='MANAGER' and deptno<> ere (job='MANAGER' and hiredate like '1981-01') or (job='MANAGER' and deptno<>' ere (job='MANAGER' and hiredate like '1981-0') or (job='MANAGER' and deptno<>'1 ere (job='MANAGER' and hiredate like '1981-') or (job='MANAGER' and deptno<>'10 ere (job='MANAGER' and hiredate like '1981') or (job='MANAGER' and deptno<>'10' ere (job='MANAGER' and hiredate like '1981%') or (job='MANAGER' and deptno<>'10 ere (job='MANAGER' and hiredate like '1981%') or (job='MANAGE' and deptno<>'10' ere (job='MANAGER' and hiredate like '1981%') or (job='MANAG' and deptno<>'10') ere (job='MANAGER' and hiredate like '1981%') or (job='MANA' and deptno<>'10') ere (job='MANAGER' and hiredate like '1981%') or (job='MAN' and deptno<>'10') o ere (job='MANAGER' and hiredate like '1981%') or (job='MA' and deptno<>'10') or ere (job='MANAGER' and hiredate like '1981%') or (job='M' and deptno<>'10') or ere (job='MANAGER' and hiredate like '1981%') or (job='' and deptno<>'10') or ( ere (job='MANAGER' and hiredate like '1981%') or (job='A' and deptno<>'10') or ere (job='MANAGER' and hiredate like '1981%') or (job='AN' and deptno<>'10') or ere (job='MANAGER' and hiredate like '1981%') or (job='ANA' and deptno<>'10') o ere (job='MANAGER' and hiredate like '1981%') or (job='ANAL' and deptno<>'10') ere (job='MANAGER' and hiredate like '1981%') or (job='ANALY' and deptno<>'10') ere (job='MANAGER' and hiredate like '1981%') or (job='ANALYS' and deptno<>'10' ere (job='MANAGER' and hiredate like '1981%') or (job='ANALYST' and deptno<>'10 ere (job='MANAGER' and hiredate like '1981%') or (job='ANALYST' and deptno<>'10 ') or ((job='CLERK' or job='SALESMAN') and sal<'2000'); ename | job | sal | hiredate | zvyseny plat --------+----------+---------+------------+-------------- BLAKE | MANAGER | 2850.00 | 1981-05-01 | 3135.000 CLARK | MANAGER | 1500.00 | 1981-06-09 | 1650.000 JONES | MANAGER | 2975.00 | 1981-04-02 | 3272.500 MARTIN | SALESMAN | 1250.00 | 1981-09-28 | 1375.000 ALLEN | SALESMAN | 1600.00 | 1981-02-20 | 1760.000 TURNER | SALESMAN | 1500.00 | 1981-09-08 | 1650.000 JAMES | CLERK | 950.00 | 1981-12-03 | 1045.000 WARD | SALESMAN | 1250.00 | 1981-02-22 | 1375.000 FORD | ANALYST | 3000.00 | 1981-12-03 | 3300.000 SMITH | CLERK | 800.00 | 1980-12-17 | 880.000 SCOTT | ANALYST | 3000.00 | 1982-12-09 | 3300.000 ADAMS | CLERK | 1100.00 | 1983-01-12 | 1210.000 MILLER | CLERK | 1300.00 | 1982-01-23 | 1430.000 (13 rows) zajicek=> select ename,job,sal,hiredate,sal*'1.1' as "zvyseny plat" from emp wh ere (job='MANAGER' and hiredate like '1981%') or (job='ANALYST' and deptno<>'10 zajicek=> zajicek=> select round(1234.56,1); round -------- 1234.6 (1 row) zajicek=> select round(1234.56,-2); round ------- 1200 (1 row) zajicek=> select round(1234.56); round ------- 1235 (1 row) zajicek=> select round(123456, -5); round -------- 100000 (1 row) zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat" zajicek-> from emp; meno | okruhly plat --------+-------------- KING | 5000 BLAKE | 2900 CLARK | 1500 JONES | 3000 MARTIN | 1300 ALLEN | 1600 TURNER | 1500 JAMES | 1000 WARD | 1300 FORD | 3000 SMITH | 800 SCOTT | 3000 ADAMS | 1100 MILLER | 1300 (14 rows) zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", trunc(sal,-2 ) as "prispevok" from emp; meno | okruhly plat | prispevok --------+--------------+----------- KING | 5000 | 5000 BLAKE | 2900 | 2800 CLARK | 1500 | 1500 JONES | 3000 | 2900 MARTIN | 1300 | 1200 ALLEN | 1600 | 1600 TURNER | 1500 | 1500 JAMES | 1000 | 900 WARD | 1300 | 1200 FORD | 3000 | 3000 SMITH | 800 | 800 SCOTT | 3000 | 3000 ADAMS | 1100 | 1100 MILLER | 1300 | 1300 (14 rows) zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", trunc(sal,-2 zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", trunc(sal,-2 zajicek=> zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", trunc(sal,-2 zajicek=> zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", trunc(sal,-2 zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", strunc(sal,- zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", satrunc(sal, zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", saltrunc(sal zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", sal-trunc(sa zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", sal-trunc(sa l,-2) as "prispevok" from emp; meno | okruhly plat | prispevok --------+--------------+----------- KING | 5000 | 0.00 BLAKE | 2900 | 50.00 CLARK | 1500 | 0.00 JONES | 3000 | 75.00 MARTIN | 1300 | 50.00 ALLEN | 1600 | 0.00 TURNER | 1500 | 0.00 JAMES | 1000 | 50.00 WARD | 1300 | 50.00 FORD | 3000 | 0.00 SMITH | 800 | 0.00 SCOTT | 3000 | 0.00 ADAMS | 1100 | 0.00 MILLER | 1300 | 0.00 (14 rows) zajicek=> select ename,sal,comm,sal mod comm as "nasobok" from emp where not nu ll(sal); ERROR: parser: parse error at or near "mod" zajicek=> select ename,sal,comm,sal mod comm as "nasobok" from emp where not nu zajicek=> select ename as "meno", round(sal,-2) as "okruhly plat", sal-trunc(sa zajicek=> select ename,sal,comm,sal mod comm as "nasobok" from emp where not nu zajicek=> select ename,sal,comm,sal mod comm) as "nasobok" from emp where not n zajicek=> select ename,sal,comm,(sal mod comm) as "nasobok" from emp where not zajicek=> select ename,sal,comm,(sal mo comm) as "nasobok" from emp where not n zajicek=> select ename,sal,comm,(sal m comm) as "nasobok" from emp where not nu zajicek=> select ename,sal,comm,(sal comm) as "nasobok" from emp where not nul zajicek=> select ename,sal,comm,(sal / comm) as "nasobok" from emp where not nu zajicek=> select ename,sal,comm,(sal / comm) as "nasobok" from emp where not nu ll(sal); ERROR: parser: parse error at or near "(" zajicek=> select ename,sal,comm,(sal / comm) as "nasobok" from emp where not nu zajicek=> select ename,sal,comm,(sal / comm as "nasobok" from emp where not nul zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null (sal); ERROR: parser: parse error at or near "(" zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null sal; ERROR: Attribute 'nullsal' not found zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null sal; ERROR: parser: parse error at or near "sal" zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not null zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not nuls zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not nusa zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not nsal zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where not sal; zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where notsal; zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sal<>nul l; ename | sal | comm | nasobok -------+-----+------+--------- (0 rows) zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sal<>nul zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sal<>nu; zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sal<>n; zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sal is n ot null; ERROR: division by zero on numeric zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sal is n zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where sa is no zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where s is not zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where is not zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where c is not zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where co is no zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where com is n zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm is zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm is zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm is; zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm i; zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm is not null and comm<>0; ename | sal | comm | nasobok --------+---------+---------+-------------- MARTIN | 1250.00 | 1400.00 | 0.8928571429 ALLEN | 1600.00 | 300.00 | 5.3333333333 WARD | 1250.00 | 500.00 | 2.5000000000 (3 rows) zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm is zajicek=> zajicek=> select ename,sal,comm,sal / comm as "nasobok" from emp where comm is zajicek=> select zajicek=> select current_date +21 zajicek-> ; ?column? ------------ 2001-11-01 (1 row) zajicek=> select current_date +21 as "o tri tyzdne"; o tri tyzdne -------------- 2001-11-01 (1 row) zajicek=> select current_date; date ------------ 2001-10-11 (1 row) zajicek=> select ename as "meno", zajicek-> hiredate as "datum nastupu", zajicek-> current_date-hiredate as "pocet odpracovanych dni" from emp; meno | datum nastupu | pocet odpracovanych dni --------+---------------+------------------------- KING | 1981-11-17 | 7268 BLAKE | 1981-05-01 | 7468 CLARK | 1981-06-09 | 7429 JONES | 1981-04-02 | 7497 MARTIN | 1981-09-28 | 7318 ALLEN | 1981-02-20 | 7538 TURNER | 1981-09-08 | 7338 JAMES | 1981-12-03 | 7252 WARD | 1981-02-22 | 7536 FORD | 1981-12-03 | 7252 SMITH | 1980-12-17 | 7603 SCOTT | 1982-12-09 | 6881 ADAMS | 1983-01-12 | 6847 MILLER | 1982-01-23 | 7201 (14 rows) zajicek=> trunc((current_date-hiredate)/2 as "pocet odpracovanych dni" from emp zajicek=> trunc((current_date-hiredate)/25 as "pocet odpracovanych dni" from em zajicek=> trunc((current_date-hiredate)/256 as "pocet odpracovanych dni" from e zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych dni" from zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych dn" from e zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych d" from em zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych " from emp zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych r" from em zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych ro" from e zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rok" from zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych roko" from zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro m emp; ERROR: parser: parse error at or near "trunc" zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek=> current_date-hiredate as "pocet odpracovanych dni" from emp; zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek=> zajicek=> ; zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek=> current_date-hiredate as "pocet odpracovanych dni" from emp; zajicek=> select ename as "meno", zajicek-> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek-> current_date-hiredate as "pocet odpracovanych dni" from emp; zajicek-> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro m emp; ERROR: Function 'trunc(int4)' does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts zajicek=> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek=> select ename as "meno", zajicek=> select ename as "meno", zajicek-> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek-> select ename as "meno", zajicek-> trunc((current_date-hiredate)/256) as "pocet odpracovanych rokov" fro zajicek-> trunc(current_date-hiredate)/256) as "pocet odpracovanych rokov" from zajicek-> trun(current_date-hiredate)/256) as "pocet odpracovanych rokov" from zajicek-> tru(current_date-hiredate)/256) as "pocet odpracovanych rokov" from e zajicek-> tr(current_date-hiredate)/256) as "pocet odpracovanych rokov" from em zajicek-> t(current_date-hiredate)/256) as "pocet odpracovanych rokov" from emp zajicek-> (current_date-hiredate)/256) as "pocet odpracovanych rokov" from emp; zajicek-> (current_date-hiredate)/256 as "pocet odpracovanych rokov" from emp; zajicek-> (current_date-hiredate)/256 as "pocet odpracovanych rokov" from emp; meno | pocet odpracovanych rokov --------+--------------------------- KING | 28 BLAKE | 29 CLARK | 29 JONES | 29 MARTIN | 28 ALLEN | 29 TURNER | 28 JAMES | 28 WARD | 29 FORD | 28 SMITH | 29 SCOTT | 26 ADAMS | 26 MILLER | 28 (14 rows) zajicek=> select to_char(current_date,'dd.mm (yy)'); to_char ------------ 11.10 (01) (1 row) zajicek=> select to_char(current_date,'dd.mm (yyyy)'); to_char -------------- 11.10 (2001) (1 row) zajicek=> select to_char(current_date,'ddd.mm (yyyy)'); to_char --------------- 284.10 (2001) (1 row) zajicek=> select to_char(current_date,'d.mm (yyyy)'); to_char ------------- 5.10 (2001) (1 row) zajicek=> select ename||' '||to_number(sal,99999) from emp; ERROR: Function 'to_number(numeric, int4)' does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts zajicek=> select ename||' '||to_char(sal,'99999') from emp; ?column? --------------- KING 5000 BLAKE 2850 CLARK 1500 JONES 2975 MARTIN 1250 ALLEN 1600 TURNER 1500 JAMES 950 WARD 1250 FORD 3000 SMITH 800 SCOTT 3000 ADAMS 1100 MILLER 1300 (14 rows) zajicek=> select ename, sal, 12*sal+coalesce(comm,0) as "roc. prijem" from emp; zajicek=> select ename, sal, 12*sal+coalesce(comm,0) as "roc. prijem" from emp; ename | sal | roc. prijem --------+---------+------------- KING | 5000.00 | 60000.00 BLAKE | 2850.00 | 34200.00 CLARK | 1500.00 | 18000.00 JONES | 2975.00 | 35700.00 MARTIN | 1250.00 | 16400.00 ALLEN | 1600.00 | 19500.00 TURNER | 1500.00 | 18000.00 JAMES | 950.00 | 11400.00 WARD | 1250.00 | 15500.00 FORD | 3000.00 | 36000.00 SMITH | 800.00 | 9600.00 SCOTT | 3000.00 | 36000.00 ADAMS | 1100.00 | 13200.00 MILLER | 1300.00 | 15600.00 (14 rows) zajicek=> select ename, sal, 12*sal+coalesce(comm,0) as "roc. prijem" from emp; zajicek=> zajicek=> select ename, coalesce(to_char(comm),'nema') as odmena from emp; ERROR: Function 'to_char(numeric)' does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts zajicek=> select ename, coalesce(to_char(comm),'nema') as "odmena" from emp; ERROR: Function 'to_char(numeric)' does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts zajicek=> select ename, coalesce(to_char(comm,'99),'nema') as "odmena" from emp zajicek=> select ename, coalesce(to_char(comm,'999),'nema') as "odmena" from em zajicek=> select ename, coalesce(to_char(comm,'9999),'nema') as "odmena" from e zajicek=> select ename, coalesce(to_char(comm,'99999),'nema') as "odmena" from zajicek=> select ename, coalesce(to_char(comm,'999999),'nema') as "odmena" from zajicek=> select ename, coalesce(to_char(comm,'99999),'nema') as "odmena" from zajicek=> select ename, coalesce(to_char(comm,'99999'),'nema') as "odmena" from zajicek=> select ename, coalesce(to_char(comm,'99999'),'nema') as "odmena" from emp; ename | odmena --------+-------- KING | nema BLAKE | nema CLARK | nema JONES | nema MARTIN | 1400 ALLEN | 300 TURNER | 0 JAMES | nema WARD | 500 FORD | nema SMITH | nema SCOTT | nema ADAMS | nema MILLER | nema (14 rows) zajicek=> select ename, coalesce(to_char(comm,'99999'),'nema') as "odmena" from zajicek=> zajicek=> select ename, job, sal, zajicek-> case when job='MANAGER' then sal+100 zajicek-> when job='CLERK' then sal*2 zajicek-> else sal+50 zajicek-> end as "zv plat" from emp; ename | job | sal | zv plat --------+-----------+---------+--------- KING | PRESIDENT | 5000.00 | 5050.00 BLAKE | MANAGER | 2850.00 | 2950.00 CLARK | MANAGER | 1500.00 | 1600.00 JONES | MANAGER | 2975.00 | 3075.00 MARTIN | SALESMAN | 1250.00 | 1300.00 ALLEN | SALESMAN | 1600.00 | 1650.00 TURNER | SALESMAN | 1500.00 | 1550.00 JAMES | CLERK | 950.00 | 1900.00 WARD | SALESMAN | 1250.00 | 1300.00 FORD | ANALYST | 3000.00 | 3050.00 SMITH | CLERK | 800.00 | 1600.00 SCOTT | ANALYST | 3000.00 | 3050.00 ADAMS | CLERK | 1100.00 | 2200.00 MILLER | CLERK | 1300.00 | 2600.00 (14 rows) zajicek=> quit zajicek-> shit zajicek-> ; ERROR: parser: parse error at or near "quit" zajicek=> \q