SQL to T-SQL conversion explained

  • Well guys here I'm back again.

    Thanks a lot for helping out.

    This is my real question:

    I have sql statement like

    SELECT DISTINCTROW Orders.OrderID, Orders.CustomerID, Orders.OrderDate, Orders.FreightCharge, Orders.SalesTaxRate, Sum(Clng(nz([Quantity]*[UnitPrice]*(1-[Discount]))*100)/100) AS LineTotal, Orders.ShipDate, [Sum Of Payments Query].[Total Payments] AS [Total Payments]

    FROM (Orders LEFT JOIN [Sum Of Payments Query] ON Orders.OrderID=[Sum Of Payments Query].OrderID) LEFT JOIN [Order Details] ON

     

    How to convert it to T-SQL that works on MSDE 

  • Without doing all the work for you :

    Distinctrow = Distinct

    CLONG = CONVERT(DECIMAL(18,4), Columns)

    NZ = ISNULL(Column, ValueIfNull)

  • It would look something like this

    SELECT

    DISTINCT Orders.OrderID,

    Orders.CustomerID,

    Orders.OrderDate,

    Orders.FreightCharge,

    Orders.SalesTaxRate,

    Sum(CONVERT(DECIMAL(18,4),(ISNULL([Quantity]*[UnitPrice]*(1-[Discount]),0))*100)/100) AS LineTotal,

    Orders.ShipDate,

    [Sum Of Payments Query].[Total Payments] AS [Total Payments]

    FROM

    Orders

    LEFT

    OUTER JOIN

    [Sum Of Payments Query]

    ON Orders.OrderID=[Sum Of Payments Query].OrderID

    LEFT OUTER

     JOIN

    [Order Details]

    ON ....

    Prasad Bhogadi
    www.inforaise.com

  • Thanks a lot. That really works.

    Can you tell me is there any T-SQL free course on the net

  • There's a free course on your computer (assuming it was installed with your client tools), called SQL Server Books Online.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply