473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

selecting in reverse order

I am doing a simple query like col1, col2, date, col4 from table1.
All four colums are of type blob. For date column, I store a string
like this:

Fri Feb 13 11:01:24 2004

I store records as they come in so the oldest record is at the top of
the table. When I select and display, I want to display them in
reverse order (newest record at the top) but I can't sort on date with
strings like that.

Is there any way to do this w/o changing my column types or creating a
temporary table? I guess I can store all the rows temporarily in a
variable and print them out in reverse order but that's not an option.
I am looking a SQL way to accomplish this. Thanks.

-James
Jul 19 '05 #1
3 2745
James Lee wrote:
I store records as they come in so the oldest record is at the top of
the table.
There is no guarantee that they come in that order. You should always
use "order by" when you want your rows in specific order.
Is there any way to do this w/o changing my column types or creating a
temporary table?


You can add a new column to your table. And order rows according to
that. You can use either id values or timestamp or other column type,
what ever you prever to use for ordering the rows. You will also need to
fill your new column with proper values. You could try parsing the date
string to get the proper values for the new column.

You can also try parsing your date string to figure out the order of
rows, but that will be slow.
Jul 19 '05 #2
James Lee wrote:
I store records as they come in so the oldest record is at the top of
the table.
There is no guarantee that they come in that order. You should always
use "order by" when you want your rows in specific order.
Is there any way to do this w/o changing my column types or creating a
temporary table?


You can add a new column to your table. And order rows according to
that. You can use either id values or timestamp or other column type,
what ever you prever to use for ordering the rows. You will also need to
fill your new column with proper values. You could try parsing the date
string to get the proper values for the new column.

You can also try parsing your date string to figure out the order of
rows, but that will be slow.
Jul 19 '05 #3
James Lee wrote:
I store records as they come in so the oldest record is at the top of
the table.
There is no guarantee that they come in that order. You should always
use "order by" when you want your rows in specific order.
Is there any way to do this w/o changing my column types or creating a
temporary table?


You can add a new column to your table. And order rows according to
that. You can use either id values or timestamp or other column type,
what ever you prever to use for ordering the rows. You will also need to
fill your new column with proper values. You could try parsing the date
string to get the proper values for the new column.

You can also try parsing your date string to figure out the order of
rows, but that will be slow.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: R. Rajesh Jeba Anbiah | last post by:
Unfortunately, I couldn't find any way to traverse the object array in reverse order. I'd thought there must be a way to do it with for..in loop, but couldn't find anything yet. Could someone...
14
by: ford_desperado | last post by:
Why isn't ALLOW REVERSE SCANS the default? Why do we have to - drop PK - create an index - recreate PK What are the advantages of indexes that do not allow reverse scans?
6
by: Zri Man | last post by:
I'm relatively new to DB2 and was reasonably amused to see the REVERSE SCAN availability for Indexes. My assumptions are as follows: DB2/UDB uses B-Tree for indexing by default and is likely...
20
by: sahukar praveen | last post by:
Hello, I have a question. I try to print a ascii file in reverse order( bottom-top). Here is the logic. 1. Go to the botton of the file fseek(). move one character back to avoid the EOF. 2....
19
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e.,...
10
by: aatish19 | last post by:
1: Write a program that asks the user to input an integer value and print it in a reverse order Sample Output Enter any number 65564 Reverse of 65564 is 46556 2: Write a program that takes a...
20
by: mike7411 | last post by:
Is there any easy way to reverse the order of the bits in a byte in C++? (i.e. 00000001 becomes 10000000)
5
by: Matt B | last post by:
I know this is a bit of nonstandard behavior, but I would like the Enter key to move focus through a group of radiobuttons without selecting them. The user would then have to use Space or actually...
40
by: KG | last post by:
Could any one tell me how to reverse the bits in an interger?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.