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 2005 Forums
 Transact-SQL (2005)
 Sorting data Problem

Author  Topic 

sadiqmodan
Starting Member

16 Posts

Posted - 2010-09-01 : 05:49:14
Hello, I have sorting problem in SQL for text data.

I have data in table like below:
================================
AA
totchip
v(389)+v(392)
Q1 Alliant Insurance Services accessibility -
Q1 Over The Past Seven Days
Q1a. Miles Driven Per Year
Q1b. First Brand To Come To Mind - Unaided
Q1_1 Optimum WiFi Awareness Summary
Q.1 Organization Type
QD1 Marital status
QSC1a Age of Children
Q2. Relationship With Aon
Q2. Which of the following broker.
Q2a. Unaided Ad Awareness
Q2-3. Would Consider - Maintenance Work
Q.2_3 Importance of Workstation Manufacturer Characteristics
QSC2 Occupation
QS2. Repair Work
Q.2b Only Server Brand
QB2b_23 Brand Imagery - Store brand - Makes me feel empowered
Q.D Decision making role

Sorting Rule : [b]It should be sorted by letter and then by number /b]

Please help : )

sadiqmodan
Starting Member

16 Posts

Posted - 2010-09-01 : 09:22:26
Hello,

Any one is there to Help me, I am stuck in this sorting issue........................:(
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-01 : 10:09:56
Not sure what your problem is. Isn't the solution just this

DECLARE @foo TABLE (
[ID] INT IDENTITY(1,1) PRIMARY KEY
, [field] VARCHAR(512)
)

INSERT @foo ([field])
SELECT 'AA'
UNION SELECT 'totchip'
UNION SELECT 'v(389)+v(392)'
UNION SELECT 'Q1 Alliant Insurance Services accessibility -'
UNION SELECT 'Q1 Over The Past Seven Days '
UNION SELECT 'Q1a. Miles Driven Per Year'
UNION SELECT 'Q1b. First Brand To Come To Mind - Unaided'
UNION SELECT 'Q1_1 Optimum WiFi Awareness Summary'
UNION SELECT 'Q.1 Organization Type'
UNION SELECT 'QD1 Marital status'
UNION SELECT 'QSC1a Age of Children'
UNION SELECT 'Q2. Relationship With Aon'
UNION SELECT 'Q2. Which of the following broker.'
UNION SELECT 'Q2a. Unaided Ad Awareness'
UNION SELECT 'Q2-3. Would Consider - Maintenance Work'
UNION SELECT 'Q.2_3 Importance of Workstation Manufacturer Characteristics'
UNION SELECT 'QSC2 Occupation'
UNION SELECT 'QS2. Repair Work'
UNION SELECT 'Q.2b Only Server Brand'
UNION SELECT 'QB2b_23 Brand Imagery - Store brand - Makes me feel empowered'
UNION SELECT 'Q.D Decision making role'

-- Ordered by letter then number???
SELECT [field] FROM @foo ORDER BY [field]

Please post sample table structure if that's not correct.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-01 : 10:10:20
results

AA
Q.1 Organization Type
Q.2_3 Importance of Workstation Manufacturer Characteristics
Q.2b Only Server Brand
Q.D Decision making role
Q1 Alliant Insurance Services accessibility -
Q1 Over The Past Seven Days
Q1_1 Optimum WiFi Awareness Summary
Q1a. Miles Driven Per Year
Q1b. First Brand To Come To Mind - Unaided
Q2-3. Would Consider - Maintenance Work
Q2. Relationship With Aon
Q2. Which of the following broker.
Q2a. Unaided Ad Awareness
QB2b_23 Brand Imagery - Store brand - Makes me feel empowered
QD1 Marital status
QS2. Repair Work
QSC1a Age of Children
QSC2 Occupation
totchip
v(389)+v(392)



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -