Msg 102, Niveau 15, État 1, Ligne 2 Syntaxe incorrecte vers 'order'.

  • SELECT codart,quantite,datfac
    ,count(quantite) over (partition by codart order by codart ) as qte
    FROM MOUVEMENT where codart is not null

  • What is your question?

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • COUNT doesn't need an ORDER BY in the OVER clause.  And as you and I have just learned, not only is it not needed, it's not permitted either.
    SELECT
       codart
    , quantite
    , datfac
    , COUNT(quantite) OVER (PARTITION BY codart) AS qte
    FROM MOUVEMENT
    WHERE codart IS NOT NULL

    John

  • That syntax is only allowed starting on SQL Server 2012. You seem to be working on 2008, so that would be a problem.
    Try using ROW_NUMBER() instead of COUNT(). In this case, it should give the same result.

    EDIT: Si t'as besoin d'aide en Francais, dis-le. Je peux essayer de repondre.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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