Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
avg with subquery
--PostgreSQL 9.5 CREATE TABLE apps(id serial PRIMARY KEY, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, published BOOLEAN, mean_rating FLOAT); INSERT INTO apps(published) VALUES (true), (true), (true), (false); CREATE TABLE reviews(id serial PRIMARY KEY, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, comment TEXT, app_id INT, rating FLOAT DEFAULT 0, CHECK (rating BETWEEN 0 AND 5)); INSERT INTO reviews(app_id, rating) VALUES (1, 2), (1, 3), (2, 3), (4, 5); UPDATE apps SET mean_rating = (SELECT AVG(rating) FROM reviews WHERE reviews.app_id = apps.id); SELECT * FROM apps;
run
|
edit
|
history
|
help
0
create myStudents table
sql
LeetCode 178
Studco
jsonb handle
Shortest "path" between two employees across companies
Assignment 1(SET A)
Codigo_Completo
Dashes in numbers
yordan