directxBOB
asked on
Select using Substring + a Join
I have the following:
select Top(5) substring(ParentId, 0, charindex('-',ParentId,1)) as Parent from assets
1. :
2. : 72
3. : 51
4. : 168
5. : 111
and I have:
select Top(5) parentid from assets
which gives:
1. : 56
2. : 72-10672
3. : 51-10610
4. : 168-10658
5. : 111-10624
How would I go about doing a join where I include ALL parentID's which do not have a - ? and where it uses the first select statement to extract the first part of the ParentID?
select Top(5) substring(ParentId, 0, charindex('-',ParentId,1))
1. :
2. : 72
3. : 51
4. : 168
5. : 111
and I have:
select Top(5) parentid from assets
which gives:
1. : 56
2. : 72-10672
3. : 51-10610
4. : 168-10658
5. : 111-10624
How would I go about doing a join where I include ALL parentID's which do not have a - ? and where it uses the first select statement to extract the first part of the ParentID?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.