Jump to content

Issues with SELECT DISTINCT


rdmusn2005

Recommended Posts

Ok, next issue. I've studied the parameters for the DISTINCT tab. Forums, help, etc. I know that the DISTINCT value returns a single entry for a column of data. For instance, if you have 15 entries in the Week column, but 8 are Week 1, and 7 are week 2.... it should return a single value of Week 1 and Week 2. Here is there problem:

 

Code:

'Now, we create the LARGE data_table of content from the other database for this rate.
Set WeekObj = Server.CreateObject("ADODB.Recordset")
SQLQuery = "SELECT DISTINCT WeekID FROM IC_Course WHERE DayID <= 6"
response.write(SQLQuery)
'Set WeekObj = CourseConn.Execute(SQLQuery)
WeekObj.Open SQLQuery, CourseConn,1,1
If Not WeekObj.EOF Then
Dim RC
RC = WeekObj.Recordcount
Do While RC > 0
Response.Write("<br>Weeks Returned:<br>")
Response.Write(WeekObj.Fields("WeekID").Value)
Response.Write("<br>")
RC = RC - 1
Loop
Else
Response.Write("No Data Returned.")
End If
I should be getting this:
Weeks Returned:
1
2
Instead, I get:
Weeks Returned:
1
Weeks Returned:
1
It repeats just week 1. Have I formatted the loop wrong?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...