can i use over clause after having on sql server 2012 ?

ahmed salah 3,216 Reputation points
2021-03-15T20:56:36.72+00:00

can i use over clause after having on sql server 2012 ?
I have technical question
can i use over clause over count on having clause
as example

select partid,product
from product
having count(partid) over

are this valid please answer me

what i know is over can use before from
but are this possible after having
having over partition or
having over order by

Developer technologies | Transact-SQL
SQL Server | Other
{count} votes

Accepted answer
  1. EchoLiu-MSFT 14,621 Reputation points
    2021-03-16T02:10:05.957+00:00

    Windowed functions can only appear in the SELECT or ORDER BY clauses.The example mentioned in your question is invalid and will return an error:

        select partid,product
        from product
        having count(partid) over
    

    Having is to specify filter conditions for the group or or an aggregate returned in the previous step.

    Echo

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Guoxiong 8,206 Reputation points
    2021-03-15T21:07:28.697+00:00

    You cannot use the OVER clause in the HAVING clause. Give some examples and tell what you want to do.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.