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

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,325 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
{count} votes

Accepted answer
  1. EchoLiu-MSFT 14,581 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,201 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.