Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Code Change

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2009-07-20 : 10:40:59
Hallo,

The following code shown below works very fine. However, it uses the OVER syntax which brings about the error syntax of OVER SQL construct or statement is not supported.

Please could anyone modify the select query to yield the same result but avoid using the OVER sql construct.

Thanks in Advance.

select prac_no,col_uid,audit_end,[status],stage,audit_start
from
(
select
row_number() over (partition by prac_no order by col_uid desc) as rownum,
*
from
(
SELECT TOP (100) PERCENT dbo.QryColProcessing.prac_no, MAX(dbo.QryColProcessing.col_uid) AS col_uid, MAX(dbo.QryColProcessing.audit_end)
AS audit_end, gprdsql.TblColProcessing.status, gprdsql.TblColProcessing.stage, MAX(dbo.QryColProcessing.audit_end + 1) AS audit_start
FROM gprdsql.TblColProcessing INNER JOIN
dbo.QryColProcessing ON gprdsql.TblColProcessing.col_uid = dbo.QryColProcessing.col_uid
GROUP BY dbo.QryColProcessing.prac_no, gprdsql.TblColProcessing.status, gprdsql.TblColProcessing.stage
HAVING (gprdsql.TblColProcessing.status = 'completed') AND (gprdsql.TblColProcessing.stage = 'cancelled') OR
(gprdsql.TblColProcessing.status = 'completed') AND (gprdsql.TblColProcessing.stage = 'stage 8')
) as dt
) as dt2
where rownum = 1


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-20 : 10:45:35
Before anyone starts to post something like "there is no error...".

The OP wants to use this statement in a view and also wants to use the designer for editing.
The "parser" from designer is the problem because there the syntax is unknown...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2009-07-20 : 10:48:36

How can I resolve it webfred - am using Sql 2005..

Thanks
Go to Top of Page
   

- Advertisement -