SQL Beginner

  • Actually when i run this on wamp server it shows following error

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CTE1 AS ( SELECT TOP 100 PERCENT DMS_ORG=ISNULL(a.DMS_ORG, b.DMS_Destina' at line 1

  • shikhar_0511 (8/27/2012)


    Actually when i run this on wamp server it shows following error

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CTE1 AS ( SELECT TOP 100 PERCENT DMS_ORG=ISNULL(a.DMS_ORG, b.DMS_Destina' at line 1

    You have posted this to a SQL Server 2008 forum, so naturally the query that I wrote only works there and not in MySQL.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • shikhar_0511 (8/27/2012)


    Actually when i run this on wamp server it shows following error

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CTE1 AS ( SELECT TOP 100 PERCENT DMS_ORG=ISNULL(a.DMS_ORG, b.DMS_Destina' at line 1

    please tell me , you are using Microsoft Sql Server ....:w00t::hehe:

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • could you explain the code that starts from

    SELECT c.Origin, c.Destination, c.Tonnage

    ,n=ROW_NUMBER() OVER (ORDER BY (SELECT NULL)

    -----------

    -----------

    till the end

    thnx

  • shikhar_0511 (8/27/2012)


    could you explain the code that starts from

    SELECT c.Origin, c.Destination, c.Tonnage

    ,n=ROW_NUMBER() OVER (ORDER BY (SELECT NULL)

    -----------

    -----------

    till the end

    thnx

    It assigns a row number to each row of the result of the CROSS APPLY VALUES query.

    Not that this will help you much because I have no clue if MySQL has an equivalent.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • and what does the cross apply query does ??

  • Evaluates the subquery for each row in the outer table. Again, if you're using MySQL no idea what/if the replacement is.

    If you are using MySQL, maybe a MySQL forum will help. http://www.dbforums.com has one

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 7 posts - 16 through 21 (of 21 total)

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