• engstevo (7/3/2013)


    I have tried this but my head of it department still telling me tht i have failed this is my last chance

    Write a SQL statement from the above example tables that will return the Product Name and Quantity with the maximum quantity sold per day.

    SELECT e.BuProductName,s.sum(OrderQuantity) as Sold per day

    FROM dbo.Product AS e

    INNER JOIN dbo.Transact AS s

    ON e. productID= s. productID

    Syntactically incorrect. Should read: -

    SELECT e.BuProductName,

    SUM(s.OrderQuantity) AS [Sold per day]

    FROM dbo.Product AS e

    INNER JOIN dbo.Transact AS s ON e.productID = s.productID

    GROUP BY e.BuProductName;

    However, that isn't the answer to your question. For that, we need readily consumable sample data and DDL. Take a look at this article (http://www.sqlservercentral.com/articles/Best+Practices/61537/)[/url] for the best way to ask a question on a technical forum.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/