|
Subject:
|
distinct dates
|
|
Posted By:
|
vin_0x1
|
Post Date:
|
3/11/2006 12:54:26 AM
|
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=
|
|
Reply By:
|
DaveGerard
|
Reply Date:
|
3/24/2006 2:49:22 AM
|
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
|
|
Reply By:
|
dparsons
|
Reply Date:
|
3/30/2006 8:16:51 PM
|
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."
|
|
Reply By:
|
vin_0x1
|
Reply Date:
|
4/7/2006 4:52:02 AM
|
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=
|
|
Reply By:
|
rstelma
|
Reply Date:
|
4/7/2006 10:40:59 AM
|
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.
|
|
Reply By:
|
joelchaconf
|
Reply Date:
|
4/7/2006 10:48:53 AM
|
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
|