I have theses three tables I just created in Postgres:
CREATE TABLE info_clients(id_client INT(pk),name VARCHAR(20), last_name VARCHAR(20));
CREATE TABLE customer_request(id_request INT(pk),client INT(fk),product INT(fk));
CREATE TABLE info_products(id_producto INT(pk),description VARCHAR(20),price INT);
And then I have the next query:
Show the id's of the clientes
who bought the 10 most expensive items (using a subquery):
SELECT id_client FROM info_clients
WHERE id_cliente=( SELECT client
FROM customer_request
WHERE product=( SELECT id_product
FROM info_products
ORDER BY price DESC LIMIT 10
)
);
But I keep getting the message_ subquery used as an expression returned more than one register, I don't know what am I doing wrong.