My stored procedure for monthly sales is now close to finished. The only thing left is that it prints out the "Authors" on several lines. So if a ID has several authors, it will print several lines instead of one. Can i resolve this in a Group By statement, or something else? And where should i put it?
How it is shortly showed(not with all the other stuff):
- 18.01.2014, Author 1, ItemID1
- 18.01.2014, Author 3, ItemID1
How it should be:
18.01.2014, Author 1, Author 3, ItemID1
ALTERPROCEDURE[dbo].[LOID]@month INT,@year INT,@report_source NVARCHAR(255),@is_primary INT ASSELECT Cast(isa.sales_date AS DATE)AS DATO, BV.name AS BU, isa.identifiers ASIS, BB.name AS Fo, bc.name AS AUTHOR, bk.title AS Tizx, isa.quantity, Isnull(id.sales_price, Isnull(u.sales_price, isa.sales_price))AS SALES_PRICE FROM book_sales AS isa INNERJOIN store AS BV ON bv.store_id = isa.store_id LEFTOUTERJOIN discount AS id ON id.identifiers = isa.identifiers AND id.store = BV.name AND id.from_date <= isa.sales_date AND id.to_date >= isa.sales_date AND id.to_date <'2999-01-01'LEFTOUTERJOIN discount AS u ON u.identifiers = isa.identifiers AND u.to_date ='2999-01-01'AND BV.name = u.store LEFTOUTERJOIN book_contributor AS BC ON BC.book_id = isa.book_id LEFTOUTERJOIN books AS BK ON BK.book_id = isa.book_id LEFTOUTERJOIN publisher AS BB ON bb.publisher_id = bk.publisher_id WHERE Month(isa.sales_date)=@month AND Year(isa.sales_date)=@year AND isa.report_source =@report_source AND bc.is_primary =@is_primary