bazy danych


select to_char(sysdate,'DD MM YYYY HH24:MI:SS') as "GODZINA"
from dual;

select id_os,imie1||' '|| nazwisko as "IMIE I NAZWISKO"
from osoby;

select id_os,initcap(imie1) ||' '||initcap(nazwisko) as "DANE"
from osoby;

select id_os,pensja
from zatrudnienia
order by pensja;

select id_os,pensja
from zatrudnienia
order by pensja,id_os;

select nazwisko,d_ur
from osoby
order by nazwisko,d_ur desc;

select pensja,to_char(pensja*2) as "Podwojna",to_char(pensja+100) as "Podniesiona o 100",to_char(pensja+(pensja*0.15)) as "Podniesiona o 15%"
from zatrudnienia
order by pensja desc;

select nazwa
from wydzialy
order by length(nazwa)desc;

select distinct id_os
from zatrudnienia
where id_w='2';

select nazwisko,imie1,plec
from osoby
where id_os='5';

select id_os,pensja
from zatrudnienia
where pensja<=2000
order by pensja desc,id_os;

select id_os
from zatrudnienia
where pensja>=3000 and pensja<=4000;

select id_os
from zatrudnienia
where pensja>2500 and pensja<=3300;

select imie1,imie2,d_ur
from osoby
where nazwisko='NOWAK'
order by d_ur asc;

select imie1,nazwisko
from osoby
where plec='K'
order by nazwisko,imie1;

select distinct id_os
from zatrudnienia
where id_w=1 or id_w=4 or id_w=5
order by id_os;

select id_os,nazwisko,imie1,imie2,d_ur,plec
from osoby
where (nazwisko='NOWAK' or nazwisko='LIS') and plec='K';

select imie1,imie2,nazwisko
from osoby
where nazwisko like '_U%';

select nazwisko
from osoby
where nazwisko like'%B%' or nazwisko like '%EK';

select id_os
from zatrudnienia
where do is null;

select id_os
from kierownicy
where do is not null;

select id_os,pensja
from zatrudnienia
where do is null
order by id_os;

select id_os,nazwisko,imie1
from osoby
where to_char(d_ur,'YYYY')='1978'
order by nazwisko,imie1;

select nazwisko,imie1,d_ur
from osoby
where to_char(d_ur,'MM')='05';

select nazwisko,imie1
from osoby
where to_char(d_ur,'DD mm')='12 06';

select id_os
from osoby
where (nazwisko='KULA' or nazwisko='MUREK') and to_char(d_ur,'MM YYYY')<'11 1975';

select nazwisko
from osoby
where d_ur>=to_date('15.02.1963','DD.MM.YYYY') and d_ur<=to_date('01.10.1965','DD.MM.YYYY');

select id_os,nazwisko,imie1,imie2,d_ur,plec
from osoby
where d_ur>=to_date('1980','YYYY') and d_ur<=to_date('1990','YYYY');

select to_char(d_ur,'day') as "DZIEN TYGODNIA"
from osoby
where plec='M' and nazwisko='LIS';

select d_ur
from osoby
where plec='M' and nazwisko='LIS';

select nazwisko,floor(months_between(sysdate,d_ur)/12) as "WIEK"
from osoby
order by "WIEK";

select imie1,nazwisko,case plec when 'M' then 'MEZCZYZNA' when 'K' then 'KOBIETA' end as "PLEC"
from osoby;

select imie1 as "IMIE",nazwisko as "NAZWISKO",substr(imie1,1,1)||'.'||substr(nazwisko,1,1)||'.'"INICIALY"
from osoby;

select imie1,nazwisko
from osoby
where imie2 is null and plec='M'
order by nazwisko,imie1;

select initcap(nazwa) as "NAZWA"
from wydzialy
where nazwa like '%M%' or nazwa like '__A%';

select nazwa
from stanowiska
where nazwa like '%sys%';

select nazwisko
from osoby
where nazwisko not like 'W%'
order by nazwisko;

select id_os
from zatrudnienia
where do is null and (pensja=1500 or pensja=1750 or pensja=2000 or pensja=4000 or pensja=4300);

select distinct pensja
from zatrudnienia
where pensja>1600 and pensja<=1800
order by pensja;

select distinct pensja
from zatrudnienia
where not (pensja>=1600 and pensja<=1800)
order by pensja desc;

select distinct pensja
from zatrudnienia
where not (pensja>1600 and pensja<=1800)
order by pensja desc;

select id_os,(((pensja)*2)+350) as "Po zmianie"
from zatrudnienia
where do is null
order by "Po zmianie"asc;

select imie1,nazwisko,d_ur,imie2
from osoby
where (to_char(d_ur,'MM')='07' or to_char(d_ur,'MM')='08' or to_char(d_ur,'MM')='09') and to_char(d_ur,'YYYY')='1979';

select case plec when 'M' then 'Pan ' when 'K' then 'Pani ' end
||initcap(imie1)||' '||initcap(nazwisko)||case plec when 'M'
then ' urodzony dnia 'when 'K' then ' urodzona dnia ' end||to_char(d_ur,'DD-MM-YYYY')as "INFORMACJE"
from osoby;

select imie1,nazwisko
from osoby
where to_char(d_ur,'YYYY')<'1966' and (nazwisko like '%W%' or nazwisko like '%Z%')
order by imie1,nazwisko;

select id_os
from zatrudnienia
where pensja*0.35>=1500;

select initcap(imie1) as "PIERWSZE IMIĘ",initcap(imie2) as "DRUGIE IMIĘ",initcap (NAZWISKO) as "NAZWISKO",substr(imie1,1,1)||'.'||substr(imie2,1,1)||'.'||
substr(nazwisko,1,1)||'.' as "INICJAŁY"
from osoby
order by nazwisko,imie1;

select max(pensja)
from zatrudnienia;

select max (pensja),min(pensja)
from zatrudnienia;

select max(pensja)-min(pensja)
from zatrudnienia
;

select avg(pensja)
from zatrudnienia
where do is null;

select round(avg(pensja),2)
from zatrudnienia
where do is null;

select max(pensja),min(pensja),avg(pensja)
from zatrudnienia
where id_w=1 and do is null;

select to_char(max(d_ur),'DD month YYYY') as "Najwczesniejsza data",to_char(min(d_ur),'DD month YYYY') as"Najpozniejsza data"
from osoby;

select sum(pensja)
from zatrudnienia
where do is null and id_w=2;

select max(id_os) as "Liczba_OSOB"
from osoby;

select count(id_os)
from osoby
where plec='K';

select count(distinct(nazwisko))
from osoby;

select count(d_ur)
from osoby
where to_char(d_ur,'MM')='11';

select count(imie2)
from osoby;

select id_w,min(pensja) as"MINIMALNA PENSJA",max(pensja) as "MAKSYMALNA PENSJA"
from zatrudnienia
where do is null
group by id_w;

select id_w,avg(pensja) as"SREDNIA PENSJA",count(id_os) as"LICZBA PRACOWNIKOW"
from zatrudnienia
where do is null
group by id_w
order by "LICZBA PRACOWNIKOW" desc;

select id_s,sum(pensja) as"SUMA PENSJI"
from zatrudnienia
where do is null and id_w=3
group by id_s;

select id_s,id_w,avg(pensja) as "SREDNIA PENSJA"
from zatrudnienia
where do is null
group by id_s,id_w
order by id_s,id_w;

select substr(nazwisko,1,1)as "LITERA",count(id_os)as "LICZBA OSOB"
from osoby
group by substr(nazwisko,1,1)
order by "LITERA";

select id_w
from zatrudnienia
where do is null
group by id_w
having count(id_os)>4;

select id_w
from zatrudnienia
where do is null
group by id_w
having avg(pensja)<=2700;

select id_w
from zatrudnienia
where do is null and id_s=3
group by id_w
having max(pensja)=3600;

select id_os
from zatrudnienia
group by id_os
having count(id_os)>1;

select id_w
from zatrudnienia
where do is null
group by id_w
having avg(pensja)>=1400 and avg(pensja)<=2300;

select floor(months_between(sysdate,max(d_ur))/12) as "NAJMLODSZY",
floor(months_between(sysdate,min(d_ur))/12) as "NAJSTARSZY"
from osoby;

select count(id_os)
from zatrudnienia
where do is null and id_s=1;

select count(id_os)
from osoby
where imie2 is null;

select count(id_os)
from osoby
where d_ur>to_date('01/06/1980','DD/MM/YYYY');

select count(pensja)
from zatrudnienia
where pensja>3000;

select count(distinct pensja)
from zatrudnienia;

select count(id_os)
from osoby
where (to_char(d_ur,'MM')='04' or to_char(d_ur,'MM')='05' or to_char(d_ur,'MM')='06');

select count(id_os)
from osoby
where to_char(d_ur,'day')='wtorek';

select rtrim(id_s) as "ID STANOWISKA",trim(min(pensja))as"MINIMALNA PENSJA",round(avg(pensja),2)as"SREDNIA PENSJA",max(pensja) as"MAKSYMALNA PENSJA"
from zatrudnienia
where do is null
group by id_s;

select id_s,count(id_os) as "LICZBA PRACOWNIKOW"
from zatrudnienia
where do is null
group by id_s
order by 2;

select id_s, avg(pensja) as "SREDNIA PENSJA",count(id_os) as "AKTUALNA LICZBA PRACOWNIKOW"
from zatrudnienia
where (id_w=1 or id_w=4) and do is null
group by id_s;

select id_w,sum(pensja) as "SUMA PENSJI"
from zatrudnienia
where do is null
group by id_w
order by 2;

select id_s,id_w,count(id_os) as "LICZBA PRACOWNIKOW"
from zatrudnienia
where do is null
group by id_s,id_w
order by 3 desc;

select id_w,id_s,avg(pensja) as "SREDNIA PENSJA"
from zatrudnienia
where do is null
group by id_w,id_s
order by 1,2;

select to_char(d_ur,'month')as"MIESIAC",count(id_os)as "LICZBA OSOB"
from osoby
group by to_char(d_ur,'month')
order by 2 desc;

select id_s
from zatrudnienia
where do is null
group by id_s
having min(pensja)=2000;

select id_s
from zatrudnienia
where do is null
group by id_s
having count(id_os)>5;

select id_w
from kierownicy
group by id_w
having count(id_w)=1;

select id_w
from ZATRUDNIENIA
where do is null and id_s=2
group by id_w
having avg(pensja)<=2500;

select id_os
from zatrudnienia
group by id_os
having count(id_os)=1;

select id_os,imie1,nazwisko,od,do,pensja
from osoby o join zatrudnienia z using(id_os)
order by nazwisko,imie1;

select id_os, imie1, nazwisko, pensja
from osoby o join zatrudnienia z using(id_os)
where do is null
order by nazwisko, pensja desc;

select nazwisko, d_ur
from osoby o join zatrudnienia z using(id_os)
where do is null and z.id_s=1
order by d_ur;

select imie1,nazwisko
from osoby o join zatrudnienia z using(id_os)
where do is null and plec='M' and pensja>=2700;

select id_os,w.nazwa,id_w
from zatrudnienia z join wydzialy w using(id_w)
order by id_os;

select id_os,w.nazwa as "Nazwa wydzialu", s.nazwa as "Nazwa stanowiska"
from zatrudnienia z join wydzialy w using(id_w) join stanowiska s using(id_s)
where do is null
order by id_os;

select nazwisko
from zatrudnienia z join osoby o using(id_os) join stanowiska s using(id_s)
where do is null and s.nazwa='profesor';

select imie1,nazwisko,pensja,s.nazwa,w.nazwa
from osoby o join zatrudnienia z using(id_os)
join stanowiska s using(id_s) join wydzialy w using(id_w)
where do is null
order by 2,1;

select nazwisko
from osoby o join zatrudnienia z using(id_os)
join stanowiska s using(id_s) join wydzialy w using(id_w)
where do is null and s.nazwa='asystent' and w.nazwa='MATEMATYKA';

select nazwa,id_os
from osoby o join zatrudnienia z using(id_os)full outer join wydzialy w using(id_w)
where do is null
order by w.nazwa;

select count(id_os)
from zatrudnienia z join stanowiska s using(id_s)
where do is null and s.nazwa='profesor';

select w.nazwa as "Nazwa wydzialu",count(id_os) as "Liczba aktualnych pracowników"
from zatrudnienia z join wydzialy w using(id_w)
where do is null
group by w.nazwa
order by 2 desc;

select initcap (w.nazwa) as "Nazwa wydzialu",initcap(s.nazwa) as "Nazwa stanowiska", count(id_os) as "Liczba aktualnych pracownikow"
from zatrudnienia z join wydzialy w using (id_w) join stanowiska s using(id_s)
where do is null
group by w.nazwa,s.nazwa
order by 1,2;

select w.nazwa
from zatrudnienia z join wydzialy w using(id_w)
where do is null
group by w.nazwa
having count(id_os)>5;

select NAZWA
from zatrudnienia z join wydzialy w using(id_w)
where do is null
group by nazwa
having avg(pensja)>=1800 and avg(pensja)<=2500
order by nazwa;

select w.nazwa
from zatrudnienia z join wydzialy w using(id_w) join stanowiska s using(id_s)
where do is null and s.nazwa='adiunkt'
group by w.nazwa
having count(id_os)>=2;

create table wydzialy_plec_stat as
select w.nazwa,o.plec,min(pensja)as "MINIMALNA PENSJA",
avg(pensja)as "SREDNIA PENSJA",max(pensja) as "MAKSYMALNA PENSJA"
from osoby o join zatrudnienia z using(id_os) join wydzialy w using(id_w)
where do is null
group by w.nazwa,o.plec;

select imie1,nazwisko,w.nazwa,ki.od,ki.do
from osoby o join kierownicy ki using(id_os)
join wydzialy w using(id_w)
where ki.od is not null
order by 3,4;

select imie1,imie2,nazwisko
from osoby o join kierownicy ki using(id_os)
join wydzialy w using(id_w)
where w.nazwa='EKONOMIA';

select distinct pensja
from osoby o join zatrudnienia z using(id_os)
where do is null and plec='K'
order by pensja asc;

select distinct nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and plec='M';

select nazwa
from osoby o join zatrudnienia z using(id_os) join wydzialy w using(id_w)
where do is null and imie1='EWA' and nazwisko='SOWA';

select initcap (imie1) as "Imię",initcap(Nazwisko),Pensja,initcap(s.nazwa) as "Nazwa stanowiska",initcap(w.nazwa) as"Nazwa wydzialu"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null
order by 2,1;

select id_os,imie1,imie2,nazwisko,to_char(d_ur,'DD month YYYY') as "Data urodzenia"
from osoby o join zatrudnienia z using(id_os) join wydzialy w using(id_w)
where do is null and w.nazwa='FIZYKA'
order by 4,2;

select id_os,nazwisko,floor(months_between(sysdate,d_ur)/12) as "WIEK"
from osoby o join zatrudnienia z using(id_os) join wydzialy w using(id_w)
where do is null and plec='K' and w.nazwa='MATEMATYKA' and pensja>2400;

select s.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where plec='M' and nazwisko='NOWAK';

select id_os,pensja,s.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and nazwisko like 'N%'
order by 3,2 desc;

select w.nazwa,min(pensja) as "Minimalna pensja", round(avg(pensja),2) as "Srednia pensja", max(pensja) as "Maksymalna pensja"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null
group by w.nazwa
order by 1;

select s.nazwa as "Nazwa stanowiska",count(id_os) as "Liczba aktualnych pracownikow"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null
group by s.nazwa
order by count(id_os) desc;

select w.nazwa as "Nazwa wydzialu",o.plec as "Plec",count(id_os) as "Liczba aktualnych pracownikow"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null
group by w.nazwa,o.plec
order by 3,1;

select round(avg(pensja),2) as "Srednia pensja wsrod kobiet"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and plec='K';

select s.Nazwa as "Nazwa",min(pensja) as"Minimalna pensja",avg(pensja) as "Srednia pensja",
max(pensja) as "Maksymalna pensja"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where o.d_ur>to_date('01/09/1960','DD/MM/YYYY')and do is null
group by s.nazwa
order by 1;


select w.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where o.d_urgroup by w.nazwa
order by 1;

select w.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null and s.nazwa='adiunkt'
group by w.nazwa
having min(pensja)<2500;

select sum(pensja) as "Suma Pensji",count(id_os)
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and nazwisko like '_O%';

select avg(pensja)
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null and w.nazwa='FILOLOGIA';

select s.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null
group by s.nazwa
having count(id_os)=11;

select distinct w.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null and s.nazwa='asystent';

select case plec when 'M' then 'Pan ' when 'K' then 'Pani 'end||
initcap(imie1)||' '||initcap(nazwisko)|| case plec when 'M'then ' urodzony 'when 'K' then ' urodzona 'end
||'dnia '|| to_char(d_ur,'DD.MM.YYYY')||', miejsce zatrudnienia: '||initcap(w.nazwa)||', stanowisko: '||initcap(s.nazwa)||'.' as "DANE"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null;

select imie1,nazwisko,pensja
from osoby o full outer join zatrudnienia z using(id_os)full outer join stanowiska s using(id_s)
full outer join wydzialy w using(id_w)
order by 3 desc;


/*cw4*/
select imie1,nazwisko,plec,d_ur
from osoby
where d_ur=(
select min(d_ur)
from osoby);

select id_os
from zatrudnienia
where pensja=(
select min(pensja)
from zatrudnienia);

select id_os
from zatrudnienia
where do is null and pensja=(
select min(pensja)
from zatrudnienia
where do is null);

select nazwisko,id_os,pensja
from osoby o join zatrudnienia z using(id_os)
where do is null and pensja=(
select min(pensja)
from zatrudnienia
where do is null);

select id_os,pensja
from zatrudnienia
where do is null and pensja>(
select pensja
from zatrudnienia
where do is null and id_os=10);

select nazwisko,pensja
from osoby o join zatrudnienia z using(id_os)
where do is null and pensja>(
select pensja
from osoby o join zatrudnienia z using(id_os)
where do is null and nazwisko='MUREK' and plec='K')
order by 2 desc;

select nazwisko
from osoby o join zatrudnienia z using(id_os)
where do is null and imie1=(
select imie1
from osoby o join zatrudnienia z using (id_os)
where do is null and nazwisko='NOREK');

select nazwisko
from osoby
where imie1 in (
select imie1
from osoby
where nazwisko='LIS');

select imie1,nazwisko
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and s.nazwa in(
select s.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and imie1='DANUTA' and nazwisko='MUREK');

select id_os,imie1
from osoby o join zatrudnienia z using(id_os)
where do is null and nazwisko in(
select nazwisko
from osoby o join zatrudnienia z using(id_os)
where do is null and nazwisko='LIS');

select nazwisko,imie1
from osoby o join zatrudnienia z using(id_os)
where do is null and pensja=(
select min(pensja)
from osoby o join zatrudnienia z using(id_os)
where do is null and plec ='K');

select id_os
from zatrudnienia z
where do is null and pensja>(
select avg(pensja)
from zatrudnienia z
where do is null and id_s=1) and pensja<(
select avg(pensja)
from zatrudnienia z
where do is null and id_s=2);

select imie1,nazwisko
from zatrudnienia z join osoby o using(id_os)
where do is null and pensja>(
select avg(pensja)
from zatrudnienia z
where do is null and id_s=1) and pensja<(
select avg(pensja)
from zatrudnienia z
where do is null and id_s=2)
order by nazwisko;

select id_os
from zatrudnienia z
where do is null and pensja=(
select min(pensja)
from zatrudnienia
where do is null and id_w=z.id_w);

select imie1,nazwisko,d_ur
from osoby o join zatrudnienia z using(id_os)
where od is null and pensja=(
select min(pensja)
from zatrudnienia
where do is null and z.id_w=id_w)
order by 2,1;

select id_os
from zatrudnienia z
where do is null and pensja<(
select avg(pensja)
from zatrudnienia
where do is null and id_w=z.id_w);

select nazwisko
from osoby o join zatrudnienia z using(id_os)
where do is null and pensja<(
select avg(pensja)
from zatrudnienia
where do is null and z.id_w=id_w)
order by 1;

select w.nazwa
from zatrudnienia z join wydzialy w using(id_w)
where do is null and id_s=2
group by w.nazwa
having avg(pensja)>(
select avg(pensja)
from zatrudnienia
where do is null and id_s=1
group by w.nazwa);

select id_w
from zatrudnienia z
where do is null
group by id_w
having avg(pensja)=(
select max(avg(pensja))
from zatrudnienia
where do is null
group by id_w);

select id_w
from zatrudnienia z
where do is null
group by id_w
having sum(pensja)=(
select min(sum(pensja))
from zatrudnienia
where do is null
group by id_w);

select id_w
from zatrudnienia z
where do is null and id_s=2
group by id_w
having sum(pensja)=(
select max(sum(pensja))
from zatrudnienia
where do is null and id_s=2
group by id_w);

select id_w
from zatrudnienia z
where do is null
group by id_w
having count(id_os)=(
select max(count(id_os))
from zatrudnienia
where do is null
group by id_w);

select w.nazwa
from zatrudnienia z join wydzialy w using(id_w)
where do is null
group by w.nazwa
having count(id_os)=(
select max(count(id_os))
from zatrudnienia z join wydzialy w using(id_w)
where do is null
group by w.nazwa);



select imie1,nazwisko,plec,d_ur
from osoby o
where d_ur=(
select max(d_ur)
from osoby);

select id_os
from zatrudnienia z
where do is null and pensja=(
select max(pensja)
from zatrudnienia);

select imie1,nazwisko,to_char(d_ur,'DD.MM.YYYY'),pensja
from osoby o join zatrudnienia z using(id_os)
where do is null and pensja=(
select max(pensja)
from osoby o join zatrudnienia z using(id_os));

select imie1,nazwisko,to_char(d_ur,'DD.MM.YYYY') as"DATA URODZENIA",
pensja,upper(s.nazwa) as"NAZWA_STANOWISKA",w.nazwa as"NAZWA_WYDZIALU"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w)
where do is null and pensja=(
select max(pensja)
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
join wydzialy w using(id_w));

select pensja,id_w
from zatrudnienia z join osoby o using(id_os)
where do is null and d_ur=(
select max(d_ur)
from zatrudnienia z join osoby o using(id_os));

select nazwisko,pensja
from osoby o join zatrudnienia z using(id_os)
where do is null and plec='M' and pensja=(
select min(pensja)
from osoby o join zatrudnienia z using(id_os)
where do is null and plec='M');

select imie1,imie2,nazwisko,s.nazwa as "NAZWA"
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and id_w =(
select id_w
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and nazwisko='DYBA');

select nazwisko,to_char(d_ur,'DD month YYYY') as "DATA URODZENIA"
from osoby
where nazwisko like 'K%' and d_ur=(
select min(d_ur)
from osoby
where nazwisko like 'K%');

select imie1,imie2,nazwisko
from osoby o
where d_ur=(
select d_ur
from osoby o
where id_os=1)
order by 3;

select imie1,nazwisko
from osoby o join zatrudnienia z using(id_os)
where do is null and pensja=(
select max(pensja)
from zatrudnienia
where do is null and z.id_s=id_s)
order by 2,1;

select imie1,nazwisko,s.nazwa
from osoby o join zatrudnienia z using(id_os) join stanowiska s using(id_s)
where do is null and pensja=(
select max(pensja)
from stanowiska
where do is null and id_s=s.id_s)
order by 2,1;



Wyszukiwarka

Podobne podstrony:
BAZY DANYCH Streszczenie z wykładów
Strona polecenia do bazy danych
2004 11 Porównanie serwerów relacyjnych baz danych Open Source [Bazy Danych]
MySQL Mechanizmy wewnętrzne bazy danych
Bazy danych w CAD
Postać normalna (bazy danych) – Wikipedia, wolna encyklopedia
01 Projektowanie relacyjnej bazy danych Czym jest relacyj
2004 05 Rozproszone fraktale [Bazy Danych]
bazy danych projekt infor w projekcie
Bazy danych(1)

więcej podobnych podstron