#223 Finding the House with the Highest Residents’ Purchase Amount
Find the street and house number whose residents made purchases for the largest total amount during the selected time interval:
CREATE TABLE employee (
id uuid NOT NULL,
"name" varchar(255) NOT NULL,
surname varchar(255) NOT NULL,
created_at timestamp NOT NULL,
CONSTRAINT employee_pk PRIMARY KEY (id),
CONSTRAINT employee_un UNIQUE (name, surname)
);
CREATE TABLE address (
id uuid NOT NULL,
employee_id uuid NOT NULL,
city varchar(255) NOT NULL,
street varchar(255) NOT NULL,
building int8 NOT NULL,
CONSTRAINT address_pk PRIMARY KEY (id),
CONSTRAINT address_fk FOREIGN KEY (employee_id) REFERENCES employee(id)
);
CREATE TABLE purshasing (
id uuid NOT NULL,
employee_id uuid NOT NULL,
"name" varchar(255) NOT NULL,
amount int8 NOT NULL,
created_at timestamp NOT NULL,
CONSTRAINT purshasing_pk PRIMARY KEY (id),
CONSTRAINT purshasing_fk FOREIGN KEY (employee_id) REFERENCES employee(id)
);
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor