Solved

SQL Query

Posted on 2014-01-13
2
346 Views
Last Modified: 2014-01-13
I'm trying to display the number of Compliments by month but I get the "Expected end of statement" error message.
I would appreciate your help:
i=1

do while i<=12
    sql2013 = "SELECT Count(ID) AS CountID FROM Compliments where year("OccDate")='2013' and month("OccDate")=i"
    Set rs2013 = conn.Execute(sql2013)

    compliments= rs2013("CountID")
    response.write MonthName(i) & rs2013("CountID")
    i=i+1

loop


j=1

do while j<=12
    sql2014 = "SELECT Count(ID) AS CountID FROM Compliments where year("OccDate")='2014' and month("OccDate")=j"
    Set rs2014 = conn.Execute(sql2014)

    compliments= rs2014("CountID")
    response.write MonthName(i) & rs2014("CountID")
    j=j+1

loop

Open in new window

0
Comment
Question by:romsom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39777745
Line 4 and line 17 will error out because you have included "OccDate". The quote marks terminate the string. If OccDate is a field in your table, you do not need the quote marks.
0
 

Author Closing Comment

by:romsom
ID: 39777786
Thank you very much; problem solved!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question