Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sorting fractions &

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-02 : 17:50:37
Ken writes "Hi,

Just wondering if you guys could help out with a slight problem.

Platform: SQL Server 7 / 2000 on Win NT 4.0 Server, SP6a

Background - the query results show the lengths and diameters of a group of related screws. I would like to show the text fields as the row & column headings in sorted (ascending) order. I know that in MS Access, you can use a crosstab query but it only allow you to sort on EITHER the row or column headings. If you sort by the decimal equivalent on say the row headings, the column headings go out of order.


item dia_text dia_num length_text length_num
---- -------- ------- ----------- ----------
123 1/4 0.75 1 1/2 1.5
456 3/8 0.375 3/4 0.75
789 5/16 0.3125 1/2 0.5
101 1/2 0.5 2 1/2 2.5
105 3/8 0.375 1 1/2 1.5
201 5/16 0.3125 2 1/2 2.5

and I want to show them as this (in a lookup table format):


dia_text
----------------------------------------------------
length_text | 5/16 | 3/8 | 1/2 | 1/4
----------------------------------------------------
1/2 | 789 | | |
3/4 | | 456 | |
1 1/2 | | 105 | | 123
2 1/2 | 201 | | 101 |

Is there any way to do this using temporary tables, straight SQL or some other method that I am missing totally?

Thanks!"
   

- Advertisement -