AVG using specific condition for each row I have a Quotation table with QuotationID, ClientID field.
A QuotationDetail table with QuotationID, ProductID
A Sales table with Year, ProductID, ClientID and Quantity.

I'm trying to create a view with the following columns:
QuotationID | Client Name | Product Name | Quantity2015 | Quantity2016

I am able to join the quotations table with clients and products but can't figure out how to SUM Quantity values for each view row filtering by YEAR (2015 and 2016).

PS: I did not specify but I have the Clients and Products tables with the fields I mentioned.
You could do something like this.

Quantity2015 = SUM(CASE WHEN Year = 2015 THEN QuantityTotal ELSE 0 END)
Quantity2016 = SUM(CASE WHEN Year = 2016 THEN QUantityTotal ELSE 0 END)


Not very flexible, but it does work.  You can use other aggregators than SUM as well.  

Ok, so a full query example would look like this.  You might need to correct table names (especially for Client/Product).  

SELECT Q.QuotationId
    , C.ClientName
    , P.ProductName
    , Quantity2015 = SUM(CASE WHEN S.[Year] = 2015 THEN S.Quantity ELSE 0 END)
    , Quantity2016 = SUM(CASE WHEN S.[Year] = 2016 THEN S.Quantity ELSE 0 END)
FROM Quotation AS Q
    INNER JOIN Client AS C ON C.ClientID = Q.ClientID
    INNER JOIN QuotationDetail AS QD ON QD.QuotationID = Q.QuotationID 
    INNER JOIN Product AS P ON P.ProductID = QD.ProductID
    INNER JOIN Sales AS S ON S.ProductID = QD.ProductID AND S.ClientID = Q.ClientID 
GROUP BY Q.QuotationId
    , C.ClientName
    , P.ProductName