Connecting Tech Pros Worldwide Help | Site Map

How to sort table data?

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 08:59 AM
deko
Guest
 
Posts: n/a
Default How to sort table data?

I need to import dates from a linked table then export them out as text to
an Excel spreadsheet. The problem is the dates need to be in ascending
order when I dump them out to Excel - and there's no telling what order they
are in in the linked table.

I've tried this:

INSERT INTO tblExcelData
SELECT [MeasurementId] AS TestID, [MeasurementDate] AS MeasDate,
[MeasurementTime] AS MeasTime
FROM Measurement
ORDER BY [MeasurementDate], [MeasurementTime];

But the dates don't appear in ascending order in tblExcelData.

When I dump them out to Excel, I'll need to concatenate:

MeasDate + " " + MeasTime (this is the text string goes to Excel - needs to
be text...)

So I need some way to sort the table while the data is in date format before
running another query to export as text into Excel.

What's the best way to sort the data in the table? Do I need an index?

Thanks in advance.




  #2  
Old November 13th, 2005, 09:00 AM
Arno R
Guest
 
Posts: n/a
Default Re: How to sort table data?

In your table 'Measurement' are the fields MeasurementDate and MeasurementTime date/time-fields or text?
You will need date/time fields to sort on.
[color=blue]
> What's the best way to sort the data in the table? Do I need an index?[/color]
When you use an autonumber as index, when your insert-query-records are in the right order, you will be allright.
Is there an index (maybe TestID) in your tblExcelData now?

Arno R

"deko" <deko@deko.com> schreef in bericht news:mG_7e.2826$t85.1262@newssvr21.news.prodigy.co m...[color=blue]
>I need to import dates from a linked table then export them out as text to
> an Excel spreadsheet. The problem is the dates need to be in ascending
> order when I dump them out to Excel - and there's no telling what order they
> are in in the linked table.
>
> I've tried this:
>
> INSERT INTO tblExcelData
> SELECT [MeasurementId] AS TestID, [MeasurementDate] AS MeasDate,
> [MeasurementTime] AS MeasTime
> FROM Measurement
> ORDER BY [MeasurementDate], [MeasurementTime];
>
> But the dates don't appear in ascending order in tblExcelData.
>
> When I dump them out to Excel, I'll need to concatenate:
>
> MeasDate + " " + MeasTime (this is the text string goes to Excel - needs to
> be text...)
>
> So I need some way to sort the table while the data is in date format before
> running another query to export as text into Excel.
>
> What's the best way to sort the data in the table? Do I need an index?
>
> Thanks in advance.
>
>
>[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.