How to get the sum of filtered fields in SQL How can I filtered values in SQL?

When I execute this query, I'm getting the result below.

SELECT Stock_TBL.StockID, Stock_TBL.ItemCode, Stock_TBL.ItemDescription,
       InvoiceItems_TBL.StoreName, InvoiceItems_TBL.Quantity
FROM Stock_TBL
INNER JOIN InvoiceItems_TBL ON Stock_TBL.StockID = InvoiceItems_TBL.StockID
INNER JOIN Invoice_TBL ON InvoiceItems_TBL.InvoiceNo = Invoice_TBL.InvoiceNo
GROUP BY Stock_TBL.StockID, Stock_TBL.ItemCode, Stock_TBL.ItemDescription,
         InvoiceItems_TBL.StoreName, InvoiceItems_TBL.Quantity




I want that filtered like the below screen shot. How can i do it (for this three tables are involving and only 5 stores).
You want to PIVOT the StoreName.  Try something like this:

SELECT * FROM (
  SELECT
    Stock_TBL.StockID,
    Stock_TBL.ItemCode,
    Stock_TBL.ItemDescription,
    InvoiceItems_TBL.StoreName,
    InvoiceItems_TBL.Quantity
  FROM Stock_TBL
  INNER JOIN InvoiceItems_TBL ON Stock_TBL.StockID = InvoiceItems_TBL.StockID
  INNER JOIN Invoice_TBL ON InvoiceItems_TBL.InvoiceNo = Invoice_TBL.InvoiceNo
  GROUP BY Stock_TBL.StockID, Stock_TBL.ItemCode, Stock_TBL.ItemDescription, InvoiceItems_TBL.StoreName, InvoiceItems_TBL.Quantity
) t
PIVOT ( SUM(Quantity)
  FOR StoreName IN (
    [E M B],
    [LB],
    [SHOP],
    [WAT],
    [NIH],
    [AJITH]
  )
) p


Note that you will have to specify the list of stores manually.  If you don't want to do this, then research dynamic pivot.