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

select only up to first '-' only Expand / Collapse
Author
Message
Posted Tuesday, December 10, 2013 12:10 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 like this......


House_no
6-1
6-1-2
6-1/2
6-1/78
6-12/5
6-3-124 ,hyderabad
6-3/2
6-3-19876 ,yuyu

select only first '-' only.............

I WANT OUTPUT LIKE THIS order ...........

6-1
6-1/2
6-1/78
6-3/2
6-12/5
Post #1521409
Posted Tuesday, December 10, 2013 12:15 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:45 AM
Points: 13,538, Visits: 10,412
SELECT House_no
FROM myTable
WHERE CHARINDEX('-',House_no,CHARINDEX('-',House_no,1)+1) = 0
ORDER BY House_no





How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1521410
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 @ 6:19 AM
Points: 1,075, Visits: 6,440
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 #1523053
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse