Results 1 to 2 of 2
  1. #1
    turdfergy is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    1

    Query to compare multiple fields and update another field

    Hi everyone,



    I just joined the forum and look forward to some good feedback from everyone (I have read this forum a lot for ideas/help before and am an intermediate Access/SQL user).

    Here's some basic information and I'll put an example below. I work for a cell phone carrier and working on some analysis to see how many customers have upgraded/downgraded their device. So I need to see if the customer has received multiple shipments, if the first device shipped is a "Flip Phone" and the second one shipped is a "Smartphone", I need to update another column to say "Upgrade". If it is a "flip" to "flip" with "exchange" as the order type, this is an "exchange" and "smartphone" to "flip" is a "downgrade".

    So in a nutshell, I need to compare to see if the customer numbers are the same, if they are, check the order type for "warranty exchange", check first shipment device and compare to second shipment device, then update another field.

    As a bonus, I have a table that has all the possible combinations of upgrades/downgrades/exchanges that I would like to utilize, but this is an "extra bonus" if anyone would know how to utilize this. Please let me know if more details, examples, etc. are needed and thanks for all the help in advance.

    CustNo---
    PhoneType---OrderType---ToBeUpdatedField
    001---Flip---Direct---Direct Order
    001---Smart---Direct---Upgrade

    123---Smart---Direct---Direct Order
    123---Flip---Direct---Downgrade

    456---Flip---Regular---Direct Order
    456---Flip---Exchange---Exchange
    456---Flip---Regular---Direct Order

    789---Smart---Regular---Direct Order
    789---Smart---Exchange---Exchange
    789---Smart---Regular---Direct Order

  2. #2
    NassauBob's Avatar
    NassauBob is offline Not THAT Green
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Augusta, GA
    Posts
    61
    Neat!

    Well, do you have the ability to alter the data structure? If you do, you could assign a numeric value to the types of phone, i.e. flip = 1, and smart = 2, then compare the records that way (subtract the new from the old), and have the result populate a new field, called something like upgradeVal. Then, that new field should contain only three possible values: a positive number, a zero, or a negative number! For instance, if I originally had a smartphone, but I downgraded to a flip, the the result value would be positive, right? Because 2(smart) - 1(flip) equals 1(positive). If I had simply traded my smartphone for another, the result would be zero, and a flip for a smart would equal -1, a negative value!

    In another small query, you could make three records, with two columns:

    tblUpgradeVal
    -1 upgrade
    0 exchange
    1 downgrade

    Does this all make sense? It does inside my head! LOL

    Now, that only gets you a quick and easy '*grade' type. You may have to create a subquery to only include those customers with multiple records, and with 'warranty exchange' in their order history.

    Shane

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple UPDATE in single query
    By nishezaman in forum Access
    Replies: 0
    Last Post: 12-13-2009, 01:40 AM
  2. Replies: 1
    Last Post: 12-10-2009, 08:41 PM
  3. Compare date in a sql query
    By access in forum Forms
    Replies: 2
    Last Post: 06-17-2009, 12:57 PM
  4. Replies: 1
    Last Post: 02-26-2009, 11:31 AM
  5. Replies: 1
    Last Post: 08-04-2008, 03:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums