Parse String within Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following string: 00737 013 33 02665 stored within my table as a
single field. I want to write a query which parses the string into the first
5 characters which would be 00737, the 11th and 12th character which would be
33. Is there a way to write a SQL statement which will parse this for me? If
I can't do it within a SQL statement, how would I do this? I ultimately want
to write a report against the query and group the data by the first 5
characters and then sub group the data by the 11th and 12th characters.

Thanks,
Mike
 
SELECT FieldName,
Left(FieldName, 5) AS TheFirst5,
Mid(FieldName, 11, 2) AS TheMiddle2
FROM TableName;
 
I have the following string: 00737 013 33 02665 stored within my table as a
single field. I want to write a query which parses the string into the first
5 characters which would be 00737, the 11th and 12th character which would be
33. Is there a way to write a SQL statement which will parse this for me? If
I can't do it within a SQL statement, how would I do this? I ultimately want
to write a report against the query and group the data by the first 5
characters and then sub group the data by the 11th and 12th characters.

Thanks,
Mike
Do you wish to combine the values?

NewColumn:Left([FieldName],5) & Mid([FieldName],11,2)
will return 0073733 from the above value.

Or keep them separate?
NewColumn1:Left([FieldName],5)
NewColumn2:Mid([FieldName],11,2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top