Solved

Problem SQL Code.

Posted on 2006-11-22
4
220 Views
Last Modified: 2006-11-22
Hi All.

We have a website using SQL (And we are new to SQL in web sites......)

We wish to display a summary of items from a given database table. Our current code (THAT WORKS FINE) looks like this:

<%
SQL="SELECT Distinct City FROM Listings ORDER BY City ASC"
set rs=conn.execute(SQL)
do while not rs.eof
Total = conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"'")%>

We have a variable in the table - STATUS - and this is used to determine if the property is ON or OFF the market - ON and you can view the details in the detail view - OFF - you know....

What we would like is for the 'display summary' to show only the properties that are ON the market - thereby our query needs to include an additional opperand.

we have tried the following:

Total = conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"'") AND (Status="ON"))%>

but does not work.

Can anyone help us please.

Many thanks
Andy.
0
Comment
Question by:AndyKeen
  • 3
4 Comments
 
LVL 23

Expert Comment

by:adathelad
Comment Utility
conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"' AND Status='ON'"
0
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
Comment Utility
Sorry, missed the closing bracket:
conn.execute("SELECT count(City) FROM Listings WHERE City ='"&rs("City")&"' AND Status='ON'")
0
 
LVL 1

Author Comment

by:AndyKeen
Comment Utility
What can I say - absolutely spot on - thank you.

Points are yours.


Regards
Andy.
0
 
LVL 23

Expert Comment

by:adathelad
Comment Utility
No problem
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

743 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

17 Experts available now in Live!

Get 1:1 Help Now