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 247781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:17:17+00:00 2026-05-11T21:17:17+00:00

this query give me ‘Incorrect syntax near the keyword ‘select’.’ look please below bold

  • 0

this query give me ‘Incorrect syntax near the keyword ‘select’.’ look please below bold character area.

declare @date1 smalldatetime, @date2 smalldatetime, @page nvarchar(100) ,@sum int
select @date1='2009-06-06',@date2='2009-06-13',@page='Tüm Sayfalar'
set @sum = select Sum(t.[VISITINGCOUNT]) from
(        
select count(page) as [VISITINGCOUNT],                 
     cast(DATENAME ( year ,DATE)+'-'+DATENAME (month ,DATE)+
     '-'+DATENAME (day ,DATE) as smalldatetime)  as [DATE]               
    from scr_StatisticaLog                
    where Date between @date1 and  @date2  
          and (Page=@page or  @page='Tüm Sayfalar')  and ProcessType='PageView'           
GROUP BY 
cast(DATENAME ( year ,DATE)+
'-'+DATENAME (month ,DATE)+
'-'+DATENAME (day ,DATE) as smalldatetime)) as t    

select 100*(t.[VISITINGCOUNT]/@sum),t.[DATE] from        
(        
select count(page) as [VISITINGCOUNT],                 
     cast(DATENAME ( year ,DATE)+'-'+DATENAME (month ,DATE)+
     '-'+DATENAME (day ,DATE) as smalldatetime)  as [DATE]               
    from scr_StatisticaLog                
    where Date between @date1 and  @date2  
          and (Page=@page or  @page='Tüm Sayfalar')  and ProcessType='PageView'           
GROUP BY 
cast(DATENAME ( year ,DATE)+
'-'+DATENAME (month ,DATE)+
'-'+DATENAME (day ,DATE) as smalldatetime)) as t   
  • 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-11T21:17:17+00:00Added an answer on May 11, 2026 at 9:17 pm

    I don’t believe you can have SET @var = SELECT ...

    Try the following instead:

    SELECT @sum = Sum(t.[VISITINGCOUNT]) from ...
    

    I would also like to say that seeing as all you are doing is SUM-ing a single column in your sub-query there is no point in doing the group by, or returning the second column.

    You are basically counting the number of records in various groups, then adding all the groups together. Far quicker just to count the total number of pages in total if that is all you need.

    The following would be much simpler:

    SELECT @sum = COUNT(page) FROM scr_StatisticaLog                
       WHERE Date BETWEEN @date1 AND  @date2  
       AND (Page=@page OR  @page='Tüm Sayfalar') AND ProcessType='PageView'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

why this query give me an error:ORA-01790 SELECT TO_CHAR(logical_date,'MM') MONTH FROM logical_date WHERE logical_date_type='B'
In this query: SELECT COUNT(*) AS UserCount, Company.* FROM Company LEFT JOIN User ON
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
In SQL server 2005 this query select len(cast('the quick brown fox jumped over the
i am using this query select date_time_posting from table where FROM_UNIXTIME(date_time_posting,'%d-%m-%Y')='$c_day_date' where $c_day_date is
I am using Zend_Db with the Pdo_Mysql driver. This query does not give any
This query works great: var pageObject = (from op in db.ObjectPermissions join pg in
This query is related to this one I asked yesterday. I have a radio
this query will just one row as a result myDataContext db = new myDataContext();
I have this query statement and want to only get records that has a

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.