Site Search:

Learn sql syntax and java stream api in half an hour code output

create table people (name VARCHAR(255),age INTEGER,emailAddress VARCHAR(255),gender varchar(255))
0
insert into people values ('Ted', 16, 'ted@email.com', 'MALE')
1
insert into people values ('Teder', 16, 'teder@email.com', 'MALE')
1
insert into people values ('Tedy', 26, 'tedy@email.com', 'MALE')
1
insert into people values ('Min', 36, 'min@email.com', 'MALE')
1
select * from people
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

Min
36
min@email.com
MALE

====stream=====
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

Min
36
min@email.com
MALE

select * from people where name = 'Ted'
Ted
16
ted@email.com
MALE

====stream=====
Ted
16
ted@email.com
MALE

select * from people where name like 'Te%'
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

====stream=====
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

select * from people where age > 20 and name like 'Te%'
Tedy
26
tedy@email.com
MALE

====stream=====
Tedy
26
tedy@email.com
MALE

select * from people where age < 20 and name like '%d'
Ted
16
ted@email.com
MALE

====stream=====
Ted
16
ted@email.com
MALE

select * from people where name like 'Te%' order by name asc
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

====stream=====
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

select * from people where name like 'Te%' order by name desc
Tedy
26
tedy@email.com
MALE

Teder
16
teder@email.com
MALE

Ted
16
ted@email.com
MALE

====stream=====
Tedy
26
tedy@email.com
MALE

Teder
16
teder@email.com
MALE

Ted
16
ted@email.com
MALE

select * from people where name like 'Te%' order by age asc
Teder
16
teder@email.com
MALE

Ted
16
ted@email.com
MALE

Tedy
26
tedy@email.com
MALE

====stream=====
Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

Tedy
26
tedy@email.com
MALE

select * from people where name like 'Te%' order by age desc
Tedy
26
tedy@email.com
MALE

Teder
16
teder@email.com
MALE

Ted
16
ted@email.com
MALE

====stream=====
Tedy
26
tedy@email.com
MALE

Ted
16
ted@email.com
MALE

Teder
16
teder@email.com
MALE

select count(*) from people where name like 'Te%'
3

====stream=====
3
select count(age) from people where name like 'Te%'
3

====stream=====
3
select count(name) from people where name like 'Te%'
3

====stream=====
3
select sum(age) from people where name like 'Te%'
58

====stream=====
58
select sum(age)/count(*) from people where name like 'Te%'
19

====stream=====
19.333333333333332
select max(age) from people where name like 'Te%'
26

====stream=====
26
select min(age) from people where name like 'Te%'
16

====stream=====
16
select distinct age from people where name like 'Te%'
16

26

====stream=====
16
26
select age from people where name like 'Te%'
16

16

26

====stream=====
16
16
26
Drop table people

0