Solved

Problem SQL Code.

Posted on 2006-11-22
4
254 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
ID: 17994274
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
ID: 17994277
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
ID: 17994293
What can I say - absolutely spot on - thank you.

Points are yours.


Regards
Andy.
0
 
LVL 23

Expert Comment

by:adathelad
ID: 17994329
No problem
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Database ERD 4 32
sql, case when & top 1 14 30
Scheduled bat file step with psexec in SQLServer agent job only 2 20
SQL 2012 clustering 9 13
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…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

830 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