Skip to content

Commit 8788ff7

Browse files
authored
Update README.md
Update SQL examples.
1 parent 4c24a01 commit 8788ff7

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

MongoExamples/SpringBoot/README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,35 +204,32 @@ select * from station_view;
204204
Join between collections:
205205

206206
```
207-
select
208-
s."station_id" station_id,
209-
(select t."capacity" from station_view t where t."_id" = s."station_id") capacity,
210-
min(s."num_bikes_available") min,
211-
max(s."num_bikes_available") max,
212-
round(avg(s."num_bikes_available")) avg
207+
select s."station_id" station_id,
208+
(select t."name" from station_view t where t."_id" = s."station_id") name,
209+
min(s."num_bikes_available") min,
210+
max(s."num_bikes_available") max,
211+
round(avg(s."num_bikes_available")) avg
213212
from status_view s
214213
group by s."station_id";
215214
```
216215

217216
```
218217
create view station_availability as
219-
select
220-
s."station_id" station_id,
221-
(select t."capacity" from station_view t where t."_id" = s."station_id") capacity,
222-
min(s."num_bikes_available") min,
223-
max(s."num_bikes_available") max,
224-
round(avg(s."num_bikes_available")) avg
225-
from status_view s
218+
select s."station_id" station_id,
219+
(select t."name" from station_view t where t."_id" = s."station_id") name,
220+
min(s."num_bikes_available") min,
221+
max(s."num_bikes_available") max,
222+
round(avg(s."num_bikes_available")) avg
223+
from status_view s
226224
group by s."station_id";
227225
```
228226

229227
Select stations that always had more than half capacity available:
230228

231229
```
232-
select station_id, min, max, avg, capacity
230+
select station_id, name, min, max, avg
233231
from station_availability
234-
where (capacity - min) < (capacity / 2) and
235-
capacity > 55
236-
order by min desc;
232+
where min > 20 and avg > 50
233+
order by max desc;
237234
```
238235

0 commit comments

Comments
 (0)