Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Queries

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 12-17-2009, 10:31 AM
turdfergy turdfergy is offline Windows Vista Access 2007 (version 12.0)
Novice
 
Join Date: Dec 2009
Posts: 1
turdfergy is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 02-03-2010, 06:17 PM
NassauBob's Avatar
NassauBob NassauBob is offline Windows XP Access 2003 (version 11.0)
Not THAT Green
 
Join Date: Feb 2010
Location: Coastal North Carolina
Posts: 60
NassauBob is on a distinguished road
Default

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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple UPDATE in single query nishezaman Access 0 12-12-2009 10:40 PM
Field from multiple records to multiple fields in one record HDennen Forms 1 12-10-2009 05:41 PM
Compare date in a sql query access Forms 2 06-17-2009 10:57 AM
Compare a Field to a Field in a Prior Record with Large Datasets aaron_a Access 1 02-26-2009 08:31 AM
Update a field in a table after ordering data in two other fields majamer Queries 1 08-04-2008 01:30 AM


All times are GMT -8. The time now is 01:44 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.