Solved

SQL Query

Posted on 2014-01-13
2
343 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now