Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Query Advice

Query Advice

Query Advice

I have data in the following format

part1     ABA       100
part2     BAA       150
part3     CA        100
part4     NS135     1000
part5     ABB       200
part6     DB        500

Parts that have a COMCDE field that begins with either a, B or C need to be group together under an FG column and parts with COMCDE starting with anything other than A, B or C need to be grouped as RM

What I want to end up with is the following:

FG     550
RM     1500

Can anyone advise me on how best to do this?


RE: Query Advice

Try something like:

Select IF(UCASE(LEFT(COMCDE, 1)) IN ('A', 'B', 'C'), 'FG', 'RM') as cc, sum(QTY)
from  TableName
group by cc

Pervasive Software

RE: Query Advice

I had tried that because it works in access - but Pervasive didn't like it.


RE: Query Advice

Strange...  What version of Pervasive are you using?  I tried it via PCC on some little sample tables I made in v9.1 and it worked fine.  When you tried it, did you get an error or incorrect results?

Pervasive Software

RE: Query Advice

You're right. I must have done something stupid first time around. The actual data is in two separate tables and the following worked for me:

Select IF(UCASE(LEFT("Part Master".COMCDE_01, 1)) IN ('A', 'B', 'C'), 'FG', 'RM') as cc, sum("Part Stock".QTYOH_06)
from  "Part Master" INNER JOIN "Part Stock" ON "Part Master".PRTNUM_01 = "Part Stock".PRTNUM_06
group by IF(UCASE(LEFT("Part Master".COMCDE_01, 1)) IN ('A', 'B', 'C'), 'FG', 'RM')


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close