| View previous topic :: View next topic |
| Author |
Message |
Jeremy Collins Guest
|
Posted: Tue Aug 26, 2003 7:59 am Post subject: Re: Sorting upon FileVersion |
|
|
Radu wrote:
| Quote: | Hi!
How could I retrieve a set of rows, in SQL Server 2000, sorted by
FileVersion. I have a filed which holds file versions.
|
SELECT * FROM tb_mytable ORDER BY FileVersion
This is very basic SQL - consider getting a book.
--
jc
Remove the -not from email
|
|
| Back to top |
|
 |
George Christoforakis Guest
|
Posted: Tue Aug 26, 2003 12:04 pm Post subject: Re: Sorting upon FileVersion |
|
|
It seems that you need the select FieldA, FieldB from TableA order by
FieldA
George Christoforakis.
"Radu" <vacaru (AT) amadee (DOT) com> wrote
| Quote: | Hi!
How could I retrieve a set of rows, in SQL Server 2000, sorted by
FileVersion. I have a filed which holds file versions.
Thank you!
Radu
|
|
|
| Back to top |
|
 |
Radu Guest
|
Posted: Tue Aug 26, 2003 1:25 pm Post subject: Re: Sorting upon FileVersion |
|
|
Thx
What I need is to sort upon FileVersion info, like 1.2.45.2 or 1.5.0.1
etc....
"George Christoforakis" <George.Christoforakis (AT) RatioGroup (DOT) com> wrote in
message news:3f4b4d0f (AT) newsgroups (DOT) borland.com...
| Quote: | It seems that you need the select FieldA, FieldB from TableA order by
FieldA
George Christoforakis.
"Radu" <vacaru (AT) amadee (DOT) com> wrote in message
news:3f4b0b54$1 (AT) newsgroups (DOT) borland.com...
Hi!
How could I retrieve a set of rows, in SQL Server 2000, sorted by
FileVersion. I have a filed which holds file versions.
Thank you!
Radu
|
|
|
| Back to top |
|
 |
Radu Guest
|
Posted: Tue Aug 26, 2003 2:07 pm Post subject: Re: Sorting upon FileVersion |
|
|
Fields (example):
ID : int
Version : char(20)
Name : varchar(255)
And I want to retreive the fields sorted correctly by Version...
"Ross" <polks71 (AT) hotmail (DOT) com> wrote
| Quote: | Radu wrote:
Thx
What I need is to sort upon FileVersion info, like 1.2.45.2 or 1.5.0.1
etc....
What is your table structure?
|
|
|
| Back to top |
|
 |
Ross Guest
|
Posted: Tue Aug 26, 2003 2:39 pm Post subject: Re: Sorting upon FileVersion |
|
|
Radu wrote:
| Quote: | Fields (example):
ID : int
Version : char(20)
Name : varchar(255)
And I want to retreive the fields sorted correctly by Version...
|
select ID, Name, Version from Table1 *order by Version*
The order by is the what puts them in order of Version using the
alphanumeric sorting. Since this is a character field however you will
have problems with sorting. Example:
1.12.5.6
1.24.5.6
12.34.56
2.45.67
is how the numbers are ordered using a character field. Even though
numerically 12 comes after 2, alpha the 2 comes after the 1.
You could try casting as numeric but it would have problems with
multiple decimals.
I have not found a way around this issue.
HTH,
Ross
|
|
| Back to top |
|
 |
Ray Marron Guest
|
Posted: Tue Aug 26, 2003 2:40 pm Post subject: Re: Sorting upon FileVersion |
|
|
Radu <vacaru (AT) amadee (DOT) com> wrote
....
| Quote: | What I need is to sort upon FileVersion info, like 1.2.45.2 or 1.5.0.1
....
Version : char(20)
....
And I want to retreive the fields sorted correctly by Version...
|
One possibility would be to reformat your fileversions in a sortable way in
the same varchar field, such as 0001.0002.0045.0002 or 0001.0005.0000.0001.
Another way would be to change each dot-position to a byte (if they can't go
over 255) so that 1.2.45.2 would become Chr(1)+Chr(2)+Chr(45)+Chr(2). This
could also be converted to a 32-bit Integer.
--
Ray Marron
|
|
| Back to top |
|
 |
Radu Guest
|
Posted: Tue Aug 26, 2003 2:43 pm Post subject: Re: Sorting upon FileVersion |
|
|
I was thinking exactly to that... filling up with zeroes, but I don't know
exactly how to build the query.... it seems that I don't have even a FOR
available (
I have solved the problem by retrieving all items to my app, and have them
sorted there, but I think this is an interesting problem... to have a
query-function that sorts upon a FileVersion....
Radu
"Ray Marron" <marron+delphi (AT) cableaz (DOT) com> wrote
| Quote: | Radu <vacaru (AT) amadee (DOT) com> wrote in message
news:3f4b699e (AT) newsgroups (DOT) borland.com...
...
What I need is to sort upon FileVersion info, like 1.2.45.2 or
1.5.0.1
...
Version : char(20)
...
And I want to retreive the fields sorted correctly by Version...
One possibility would be to reformat your fileversions in a sortable way
in
the same varchar field, such as 0001.0002.0045.0002 or
0001.0005.0000.0001.
Another way would be to change each dot-position to a byte (if they can't
go
over 255) so that 1.2.45.2 would become Chr(1)+Chr(2)+Chr(45)+Chr(2).
This
could also be converted to a 32-bit Integer.
--
Ray Marron
|
|
|
| Back to top |
|
 |
Ray Marron Guest
|
Posted: Tue Aug 26, 2003 4:17 pm Post subject: Re: Sorting upon FileVersion |
|
|
Radu <vacaru (AT) amadee (DOT) com> wrote
| Quote: | I was thinking exactly to that... filling up with zeroes, but I don't know
exactly how to build the query.... it seems that I don't have even a FOR
available (
|
I would most likely store them in the sortable format rather than try and
make it happen each time the query is run. That way, you only need to futz
with it when the values actually change. You can either store both the
display & sortable versions or just the sortable version and then format it
for display. In this case, you can most likely *reduce* your storage needs
by replacing your varchar(20) with an integer.
--
Ray Marron
|
|
| Back to top |
|
 |
Jeremy Collins Guest
|
Posted: Tue Aug 26, 2003 4:49 pm Post subject: Re: Sorting upon FileVersion |
|
|
Ray Marron wrote:
| Quote: | Radu <vacaru (AT) amadee (DOT) com> wrote in message
news:3f4b71fd$1 (AT) newsgroups (DOT) borland.com...
I was thinking exactly to that... filling up with zeroes, but I don't know
exactly how to build the query.... it seems that I don't have even a FOR
available (
I would most likely store them in the sortable format rather than try and
make it happen each time the query is run. That way, you only need to futz
with it when the values actually change. You can either store both the
display & sortable versions or just the sortable version and then format it
for display. In this case, you can most likely *reduce* your storage needs
by replacing your varchar(20) with an integer.
|
I'd probably use 4 integers - MajorVersion, MinorVersion, Revision,
and Build (or whatever).
It would be trivial to format this as one string for display, and much
more useful for sorting and querying.
--
jc
Remove the -not from email
|
|
| Back to top |
|
 |
Radu Guest
|
Posted: Wed Aug 27, 2003 6:47 am Post subject: Re: Sorting upon FileVersion |
|
|
Good idea!!
Thank you
"Ray Marron" <marron+delphi (AT) cableaz (DOT) com> wrote
| Quote: | Radu <vacaru (AT) amadee (DOT) com> wrote in message
news:3f4b71fd$1 (AT) newsgroups (DOT) borland.com...
I was thinking exactly to that... filling up with zeroes, but I don't
know
exactly how to build the query.... it seems that I don't have even a FOR
available (
I would most likely store them in the sortable format rather than try and
make it happen each time the query is run. That way, you only need to
futz
with it when the values actually change. You can either store both the
display & sortable versions or just the sortable version and then format
it
for display. In this case, you can most likely *reduce* your storage
needs
by replacing your varchar(20) with an integer.
--
Ray Marron
|
|
|
| Back to top |
|
 |
|