Solved

How do I split a column?

Posted on 2009-05-20
10
204 Views
Last Modified: 2012-05-07
Now I have one column that has positive and negative values, Now I want to split this column the positive and negative shoaled be separated

how do I do it?

Thanks for any help
0
Comment
Question by:AYid
[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
  • 5
  • 5
10 Comments
 
LVL 15

Expert Comment

by:MNelson831
ID: 24435327
Select
     Case
          When MyFieldValue < 0 then MyFieldValue
          Else 0
     End as MyNegNumbers,
     Case
          When MyFieldValue > 0 then MyFieldValue
          Else 0
     End as MyPosNumbers
From
     MyTableName
Where
     MyCriteria = True



     
0
 
LVL 1

Author Comment

by:AYid
ID: 24435388
I'm getting an error

syntax error
0
 
LVL 1

Author Comment

by:AYid
ID: 24435417

syntax error (missing operator) in query expression

Open in new window

0
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.

 
LVL 15

Expert Comment

by:MNelson831
ID: 24435435
Are you running this in Access or SQL?
0
 
LVL 1

Author Comment

by:AYid
ID: 24435460
Accses
0
 
LVL 15

Expert Comment

by:MNelson831
ID: 24435465
SELECT IIf([MyDataField]>0,[MyDataField],0) AS MyPosNums, IIf([MyDataField]<0,[MyDataField],0) AS MyNegNums
FROM MyTableName;
0
 
LVL 15

Expert Comment

by:MNelson831
ID: 24435476
Look in this file for example
db9.mdb
0
 
LVL 1

Author Comment

by:AYid
ID: 24435701
Thanks it works great!!!

one more thing.. what is the syntax to format it as currency?
0
 
LVL 15

Accepted Solution

by:
MNelson831 earned 125 total points
ID: 24435996
SELECT Format(IIf([MyDataField]>0,[MyDataField],0),"Currency") AS MyPosNums, Format(IIf([MyDataField]<0,[MyDataField],0),"Currency") AS MyNegNums
FROM MyTableName;

0
 
LVL 1

Author Closing Comment

by:AYid
ID: 31583663
Thanks
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 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