Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

display order by houseno Expand / Collapse
Author
Message
Posted Friday, December 6, 2013 2:35 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, April 6, 2014 12:03 AM
Points: 30, Visits: 119
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..................
Post #1520462
Posted Friday, December 6, 2013 4:42 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, December 12, 2014 5:23 AM
Points: 856, Visits: 1,504
its a cross post

you have already put same question earlier here http://www.sqlservercentral.com/Forums/Topic1511010-3077-4.aspx
Post #1520511
Posted Friday, December 6, 2013 11:51 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, April 6, 2014 12:03 AM
Points: 30, Visits: 119
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.
Post #1520789
Posted Saturday, December 7, 2013 11:00 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 1:42 PM
Points: 20,856, Visits: 32,870
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.



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)
Post #1520829
Posted Monday, December 9, 2013 4:13 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 11:04 AM
Points: 461, Visits: 691
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.

Post #1521010
Posted Sunday, December 15, 2013 11:07 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 1:05 AM
Points: 1,037, Visits: 7,018
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
Post #1523055
Posted Sunday, December 15, 2013 7:41 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 3:40 PM
Points: 170, Visits: 42
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),
...
Post #1523074
Posted Monday, December 16, 2013 12:27 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, December 12, 2014 5:23 AM
Points: 856, Visits: 1,504
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?


now these are some threads ....
Post #1523103
Posted Wednesday, December 18, 2013 2:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:14 AM
Points: 6,890, Visits: 14,253
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?


now these are some threads ....


501's, mate. Best in the world


“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
Post #1523993
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse