Reputation: 97
How can I make this query works?
I've the function top_movies_ceiling(3)
CREATE OR REPLACE FUNCTION top_movies_ceiling(n_top integer) -- n_top dos mais vendidos
RETURNS SETOF inventory AS $$
BEGIN
RETURN QUERY
SELECT *
FROM inventory
ORDER BY sales DESC
LIMIT n_top;
END;
$$LANGUAGE plpgsql;
that returns:
prod_id|quan_in_stock|sales
Now, when I run the query:
SELECT products.price
FROM products
WHERE products.prod_id = prod_id.top_movies_ceiling(3);
I get the error: schema "prod_id" does not exist
I hope that you can help me! Thanks!
Upvotes: 1
Views: 4878
Reputation: 116
The error is in:
prod_id.top_movies_ceiling(3)
that mean: function top_movies_ceiling(int) from schema prod_id.
Please enter the CREATE FUNCTION of top_movies_ceiling() for better understand what you want.
Upvotes: 1
Reputation: 51629
a wild guess - is it what you try to do?
SELECT products.price
FROM products
JOIN (select * from top_movies_ceiling(3)) top_m on top_m.prod_id = products.prod_id
;
Upvotes: 2