question

ahmedsalah-1628 avatar image
0 Votes"
ahmedsalah-1628 asked EchoLiu-msft commented

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

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-generalsql-server-transact-sql
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Do you have any update?Please also remember to accept the answers if they helped. Your action would be helpful to other users who encounter the same issue and read this thread.


Echo

0 Votes 0 ·
EchoLiu-msft avatar image
0 Votes"
EchoLiu-msft answered EchoLiu-msft edited

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GuoxiongYuan-7218 avatar image
0 Votes"
GuoxiongYuan-7218 answered GuoxiongYuan-7218 commented

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

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

can i use over statment
after from table
without having

0 Votes 0 ·

You can use it in the subquery after the FROM clause, but you cannot use it directly in the FROM clause.

0 Votes 0 ·

can you show me sample for that please

0 Votes 0 ·
Show more comments