Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2006, 01:54 AM
Authorized User
 
Join Date: Sep 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default distinct dates

I am using distinct clause in my query to get the result from database
I want to retrive various date when transaction took place.

I am writing query like this
sql="select distinct(dat_operation) from table_x order b date"

I am using order by clause but not getting dates in order.

How to solve it ?

Please help

=vineet=


 
Old March 24th, 2006, 03:49 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

2 questions for you vineet. 1)Is dat_operation the name of your date field that you desire. 2)Is 'date' the name of your date field since you are trying to order by date. Incidentally your order by is missing the 'y' in 'order by'. Furthermore DATE is a reserved word in ASP.

Here is a simple example of what I think you are looking for.

sql = "SELECT DISTINCT MyDateField FROM table_x ORDER BY MyDateField"

Dave

 
Old March 30th, 2006, 09:16 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Dave is right, however, you can use reserved words in your SQL statements by doing something like this: SELECT [date] From Table (I should probably note that this works in MSSQL and not in MySQL) And your order by is missing: Order By Date ASC or Order By Date DESC. ASC = ascending (smallest to largest) DESC = descending (largest to smallest)

"The one language all programmers understand is profanity."
 
Old April 7th, 2006, 04:52 AM
Authorized User
 
Join Date: Sep 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for reply

I am explaining my problem again

I am using distinct clause in my query to get the result from database
I want to retrive various date when transaction took place.

I am writing query like this
sql="select distinct(dat_operation) from table_x order by dat_operation"

I am using order by clause but not getting dates in order.

dat_operation is the field name of date type by which I would like to sort
How to solve it ?

Please help

=vineet=

 
Old April 7th, 2006, 10:40 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

What is the datatype of your date field? Can you post some examples of the dates that are in your date field that aren't ordering correctly? I'm running the same type of query and can't find a problem with it.

 
Old April 7th, 2006, 10:48 AM
Authorized User
 
Join Date: Mar 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had an analogous problem when I applied a function to a field in an Sql query.

My problem (using your query as example) was that the resulting record set's column field was not "dat_operation" but "distinct(dat_operation)" and I had problems extracting the information using the clause rsXX.ByFieldName("dat_operation") from the record set. This was not standard MSSQL though...

Joel





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Distinct Smeghead SQL Server 2005 9 December 17th, 2007 11:10 AM
Distinct Eddywardo SQL Server 2005 1 September 2nd, 2006 07:41 AM
Select Distinct kirkmc Access 13 July 13th, 2006 01:26 PM
distinct problem hastikeyvan Classic ASP Basics 1 September 6th, 2005 02:47 PM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.