Skip to content

Instantly share code, notes, and snippets.

@tearf001
Created July 25, 2018 06:56
Show Gist options
  • Save tearf001/e785de2640912725827516c61d478a81 to your computer and use it in GitHub Desktop.
Save tearf001/e785de2640912725827516c61d478a81 to your computer and use it in GitHub Desktop.
返回匿名表
CREATE FUNCTION extended_sales(p_itemno int)
RETURNS TABLE(quantity int, total numeric) AS $$
BEGIN
RETURN QUERY SELECT s.quantity, s.quantity * s.price FROM sales AS s
WHERE s.itemno = p_itemno;
END;
$$ LANGUAGE plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment