Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 378529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:48:13+00:00 2026-05-12T14:48:13+00:00

I am having trouble with the following query which returns the following error: ‘Article’

  • 0

I am having trouble with the following query which returns the following error:

‘Article’ is not a recognized option.
Incorrect syntax near the keyword ‘ON’

Is there something obvious wrong that you can point out??

(
@PageIndex  int,
@PageSize   int
)

WITH Article AS
(
SELECT
tbrm_Article.ArticleID, 
tbrm_Article.CountryID,
tbrm_Article.CategoryID,
tbrm_Article.Title,
tbrm_Article.ArticleDetail,
tbrm_Article.Source,
tbrm_Article.ArticleDateTimeAdded,
tbrm_Article.ViewCount,
tbrm_Article.CommentCount,
tbrm_CountryList.CountryName AS CountryName,
tbrm_CountryList.CountryImage AS CountryImage,
tbrm_CategoryList.CategoryName AS CategoryName,
tbrm_CategoryList.CategoryImage AS CategoryImage,
aspnet_Users.UserName AS UserName,
Truth,
Relevance,  
ROW_NUMBER() OVER (ORDER BY tbrm_Article.ArticleDateTimeAdded DESC) AS RowRank

FROM

tbrm_Article INNER JOIN
tbrm_CountryList ON tbrm_Article.CountryID = tbrm_CountryList.CountryID INNER JOIN
    tbrm_CategoryList ON tbrm_Article.CategoryID = tbrm_CategoryList.CategoryID INNER JOIN
    aspnet_Users ON tbrm_Article.UserID = aspnet_Users.UserID


CROSS APPLY (
SELECT tbrm_Votes.ArticleID, AVG(tbrm_Votes.Truth), AVG(tbrm_Votes.Relevance)
FROM tbrm_Votes
GROUP BY tbrm_Votes.ArticleID
) AS Votes(ArticleID,Truth,Relevance)
ON tbrm_Article.ArticleID = tbrm_Votes.ArticleID

)  SELECT * FROM Article
  WHERE Article.RowRank > @PageIndex AND RowRank <= (@PageIndex + @PageSize)
  ORDER BY Article.ArticleDateTimeAdded DESC
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:48:13+00:00Added an answer on May 12, 2026 at 2:48 pm

    You need to add a semicolon before your “WITH” (it needs to be the first statement in a batch):

    OK – update – you’re trying to do this inside a stored procedure – that changes some details…

    Try this:

    CREATE PROCEDURE dbo.MyProcedure(@PageIndex int, @PageSize int)
    AS 
    BEGIN    
        WITH Article AS
        (
          SELECT
           tbrm_Articl
        ........  // rest of your statement
    END 
    

    Does this work??

    Marc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble trying to optimize the following query for sql server 2005. Does
I am having a trouble matching a string in a MySQL-query with the following
I'm learning SQL and I'm having trouble with a query. I have the following
I am having trouble with subquery counts with JDOQL (using DataNucleus). The following query
I'm having trouble with sorting out a query for the following: Data: Column1 Column2
I'm having trouble getting the following to work in SQL Server 2k, but it
I am having trouble deleting orphan nodes using JPA with the following mapping @OneToMany
I having trouble in dividing the HTML frames. I have been using the following
I'm having some trouble with a generic method I'm writing. It has the following
I am having trouble with IE7. I have a header, which is an IMG.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.