Click here to Skip to main content
15,905,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello . i am working on my project and i have to create a sql query to achieve my aims. but unfortunately i get an error when i run the query.

here is my Sql query :

SQL
select ROW_NUMBER()
OVER (ORDER BY Advertisement.AdsDate asc ) AS AdsIndex
,Advertisement.AdsId , Advertisement.AdsEnTitle from Advertisement
where Advertisement.Status=N'True' and AdsIndex<=17 and AdsIndex>=11


Error :

XML
Invalid column name 'AdsIndex'.


how should i solve my problem ?
Posted

1 solution

Try:
SQL
SELECT AdsIndex, AdsId, AdsEnTitle 
FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY Advertisement.AdsDate ASC) AS AdsIndex
      FROM Advertisement)
WHERE Status=N'True' AND AdsIndex<=17 AND AdsIndex>=11
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900