Solved

How to split a field into two columns in a Query

Posted on 2016-10-12
6
45 Views
Last Modified: 2016-10-13
I want to be able to via a query parse a single column  Claim No (123456789-001) into two separate fields in the resulting worksheet.

So the first 9 characters and then the number to the right of the "-"
0
Comment
Question by:seamus9909
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 41841104
You need to use the left() and right() functions

Select Left([Claim No], 9) as ClaimNo, Right([Claim No], 3) as ClaimSuffix From YourTable
0
 

Author Comment

by:seamus9909
ID: 41841125
Its telling syntax is not correct.  I am using Query Design and not the SQL itself.

am I missing the quote or bracket?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41841137
<I am using Query Design and not the SQL itself.>

post an image of your query
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41841256
Pls try.. Also check the name of the column - [Claim No].

1.
left(x,instr([Claim No],"-")-1)
trim(mid(([Claim No],instr(([Claim No],"-")+1))

2.
trim(split(([Claim No],"-")(0))
trim(split(([Claim No],"-")(1))
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 41841500
In Query Design, write into the Field Option
LeftField: Left([Claim No],9)

Open in new window

This is the first field that will be selected with Alias LeftField (of course you can use your preferred name)
Then the other field will be
RightField: Right([Claim No],3)

Open in new window

Example
0
 

Author Closing Comment

by:seamus9909
ID: 41841798
Thank you so much!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question