Connecting Tech Pros Worldwide Help | Site Map

How to sort table data?

deko
Guest
 
Posts: n/a
#1: Nov 13 '05
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.



Arno R
Guest
 
Posts: n/a
#2: Nov 13 '05

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]
Closed Thread