How to present large dataset from a SQL Server query?

Need help with query on Microsoft SQL Server 2008?

  • I need to write a query that shows the most profitable order. The profit is shown on the "Extended Price" column. Here is what my output looks like: https://docs.google.com/spreadsheet/ccc?key=0AkyLVhiCpjaFdG5MT3ZsV2hiS1dWR21Vc3MxMmthS3c#gid=0 Here is what the output is supposed to look like: https://docs.google.com/spreadsheet/ccc?key=0AkyLVhiCpjaFdEJaX2hmRjZIZVMtckE4SEVOd0hMT1E#gid=0 Here is my coding so far. It comes from a view called "VExtendedDiff" SELECT OrderID "Order Number", OrderDate "Order Date", LastName "Customer Last Name", ItemID "Item Number", Description "Item Description", Quantity, Price, LastCost "Last Cost", PriceDiff "Difference Between Price and Last Cost", ExtendedDiff "Extended Price" FROM VExtendedDiff

  • Answer:

    You need to add a calculation expressions and add the ORDER BY condition: SELECT OrderID "Order Number", OrderDate "Order Date", LastName "Customer Last Name", ItemID "Item Number", Description "Item Description", Quantity, Price, LastCost "Last Cost", PriceDiff "Difference Between Price and Last Cost", ExtendedDiff "Extended Price", Quantity*Price AS Profit FROM VExtendedDiff ORDER BY Profit DESC

showtime at Yahoo! Answers Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.