Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping on first word of a field

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
Using Crystal Reports 8.5 and Oracle 9i tables:

I have a table with a text field ("{Asset Name}") where, for the most part, the first word indicates the manufacturer. I wish to create groups from the first word.

Is there a function to pull off the first word/string before a space in a text field?
 
Hi,
Yes there is..

Oh, you probably would like to know what it is right?

Try:

@GroupOnThis
{Asset Name}[1 to (Instr({Asset Name},' ') - 1)]

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I was attempting to do the same useing the "Split" function, but could not make it work. Thanks.

Now a few of the records are just one word. Not sure how Oracle pads the field, but do you think your formula will hands those records too?
 
You could use split:

if ubound(split({table.field}," ")) > 1 then
split({table.field}," ")[1] else
{table.field}

-LB
 
Hi,
LB's solution will work better with one word field data since my formula would not find a space ( unless it is an Oracle CHAR field ( instead of varchar2) and has added spaces after the end of the string) and would then try to substring from 1 to -1 - not likely to work..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top