SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


display order by houseno


display order by houseno

Author
Message
shashianireddy
shashianireddy
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 135
i have table house no like this below coloum.........

house_no

3-13-10
3-13-200/a
3-13-450/a
3-13-1345/b
3-13-12
3-13-4
3-13-567/c
3-13-832/a
3-13-943


i want table like this....
3-13-4
3-13-10
3-13-12
3-13-200/a
3-13-450/a
3-13-567/c
3-13-832/a
3-13-943
3-13-1345/b


pl write the quarie..................
twin.devil
twin.devil
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5284 Visits: 2692
its a cross post

you have already put same question earlier here http://www.sqlservercentral.com/Forums/Topic1511010-3077-4.aspx
shashianireddy
shashianireddy
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 135
it shows error like

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '17-280' to data type int.
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)

Group: General Forum Members
Points: 93905 Visits: 38955
One, reposting on a new thread isn't going to get you different answers.

Two, on your original thread, please post the code you are using. You should also take the time to read the first article I reference below in my signature block. It will walk you through what you need to post and how to post it to get the best possible answer to your question.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
aaron.reese
aaron.reese
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2397 Visits: 907
The short answer is that you should re think your database.

From the question it is clear that the field is storing at least three separate entities:

Sector (3-13) - varchar
PropertyID (414) - int
Sub Property ID (/a) - varchar

To do the sorting that you want, you will need to split the value into three, sort by the middle and last columns and then recombine the values. Longer term it would probably be better to store these permanently rather than split and recombine each time.

If you can't change the existing columns, you could possibly add computed columns to the existing table, or create a lookup table with Create, Update and Delete triggers on the existing table. Failing that, a table function would do it, but performance may take a hit, depending on the size of the dataset being processed.
ChrisM@home
ChrisM@home
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5148 Visits: 10605
Each one of your five current threads

select quarie between houseno ..........
select house_no order
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
display order by houseno

relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?


Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




Understanding and using APPLY, (I) and (II) Paul White

Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Dazli
Dazli
SSC-Enthusiastic
SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)

Group: General Forum Members
Points: 188 Visits: 87
If you have to keep the data this way, maybe can parse the hourse_no, then order by different parts.

SELECT
CAST(SUBSTRING(hourse_no,1,CHARINDEX('-',hourse_no)-1) AS INT),
CAST(SUBSTRING(hourse_no,CHARINDEX('-',hourse_no)+1,2) AS INT),
...
FROM #temp
ORDER BY
CAST(SUBSTRING(hourse_no,1,CHARINDEX('-',hourse_no)-1) AS INT),
CAST(SUBSTRING(hourse_no,CHARINDEX('-',hourse_no)+1,2) AS INT),
...
twin.devil
twin.devil
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5284 Visits: 2692
ChrisM@home (12/15/2013)
Each one of your five current threads

select quarie between houseno ..........
select house_no order
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
display order by houseno

relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?


w00t now these are some threads ....
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41024 Visits: 20000
twin.devil (12/16/2013)
ChrisM@home (12/15/2013)
Each one of your five current threads

select quarie between houseno ..........
select house_no order
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
display order by houseno

relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?


w00t now these are some threads ....


501's, mate. Best in the world :-P

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search