| Author |
Topic |
|
omoo
Starting Member
5 Posts |
Posted - 2005-11-24 : 06:40:49
|
| Hi,I have the follow records:N1235-A123-U876M2345-R434-T365N1235-A168-U824M3457-Z541-F234M4321-R354-U543I want to have the following distinct output:N1235-AM2345-RM3457-ZM4321-RThe output is the 1st 5 characrters and "-" and on more character after that. May I know how I can do this? |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2005-11-24 : 06:51:09
|
| select distinct left(field_name,7) from TablenameregardsSachinDon't sit back because of failure. It will come back to check if you still available. -- Binu |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-24 : 06:53:37
|
If the length is fixed thenSelect distinct data from ( select left(col,7) as data from yourTable ) T MadhivananFailing to plan is Planning to fail |
 |
|
|
omoo
Starting Member
5 Posts |
Posted - 2005-11-24 : 07:00:06
|
Hi, thanks for the suggestion. I got an error which says "Left:invalid identifier"I am using SQL 8.1quote: Originally posted by sachinsamuel select distinct left(field_name,7) from TablenameregardsSachinDon't sit back because of failure. It will come back to check if you still available. -- Binu
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-24 : 07:01:12
|
| Are you using SQL Server?MadhivananFailing to plan is Planning to fail |
 |
|
|
omoo
Starting Member
5 Posts |
Posted - 2005-11-24 : 07:03:33
|
I'm sorry. It's SQL 5.1quote: Originally posted by omoo Hi, thanks for the suggestion. I got an error which says "Left:invalid identifier"I am using SQL 8.1
|
 |
|
|
omoo
Starting Member
5 Posts |
Posted - 2005-11-24 : 07:04:44
|
Hmm... I am not sure but the program I am using is called "PL/SQL Developer"quote: Originally posted by madhivanan Are you using SQL Server?MadhivananFailing to plan is Planning to fail
|
 |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2005-11-24 : 07:15:35
|
| Left will work fine with SQL server. I am not aware of SQL 8.1 or SQL 5.1Don't sit back because of failure. It will come back to check if you still available. -- Binu |
 |
|
|
omoo
Starting Member
5 Posts |
Posted - 2005-11-24 : 07:21:47
|
| Hi,I have got it. I use SUBSTR(column_name, 1, 7)Thanks for the help! |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2005-11-24 : 07:27:22
|
| "PL/SQL Developer"...ORACLE????...This site deals 99.9% of the time with MSSQLdbforums.com might be a better long term bet for you. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-24 : 07:40:47
|
This is SQL Server Forum. If you are using other better to post at Relevent Forums MadhivananFailing to plan is Planning to fail |
 |
|
|
|