I have been trying to learn using the Pubs
database. I have been trying to figure out how to create a stored procedure to create a profitability column.
The current code I have is this.
SELECT DISTINCT pub_id, ((price * ytd_sales) - advance / 100 * royalty) as [Profit]
FROM titles
WHERE price IS NOT NULL
The two issues I am having are pub_id
contains duplicates since they're sorted using title_id
and one publisher can publish more than one book.
I am trying to add all the profits together and only have 1 row per publisher. And I am trying to turn that into a stored procedure.