473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Case Select on 1 to many record relationship

benchpolo
142 100+
Data
Expand|Select|Wrap|Line Numbers
  1. name_id  address_type     address1
  2. X00031   Mailing         P.O. BOX 3
  3. X00031   Home            123 S SAMPLE
  4. X00032   Home            122 W SAMPLE
  5.  
  6. select name_id,
  7. address_type, case when address_type='Mailing' then upper(address1) ..??
  8.  
I have a data set that I need to extract address_type is Mailing, but i'm having issues with our data.

Scenario: If record has both Mailing and Home filter the Mailing address, BUT if the data has only Home and no mailing address use the Home address.

Issue: With the code provided above i'm stuck! can anyone assist? appreciate it! :)
Jan 4 '12 #1
3 1592
ck9663
2,878 Expert 2GB
If the records are not in the same row, you will need to join the table to itself.

Happy Coding!!!


~~ CK
Jan 4 '12 #2
benchpolo
142 100+
Expand|Select|Wrap|Line Numbers
  1. select distinct a.name_id
  2. , a.address_type
  3. , a.address1
  4. from vw_mp_name_address a
  5. inner join vw_mp_name_address b on b.name_id = a.name_id
?? still getting both home and mailing.
Jan 4 '12 #3
ck9663
2,878 Expert 2GB
Use CASE...WHEN...END to pick which value you will use.

Happy Coding!!!


~~ CK
Jan 5 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Anand Mamuder | last post by:
Greetings, I have a table MYTABLE ( msg_id RAW(24) NOT NULL) , .....) msg_id is the key, If I wanted to select a record using the OCI, the select is failing. I can see that the value exists...
1
by: Mark Hargreaves | last post by:
Hopefully someone can help. I have two tables, namely master and postings: Fields include the following: master: staffno - int (11) primary key forename - varchar (20) surname - varchar...
0
by: Randy Harris | last post by:
If I use code to SetFocus to a continuous form, then GotoRecord, is there a Method that will then Select the Record? I'm getting to the correct record but can't find a way to select it...
1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and 5)record number. If the foreign content (FC)is >15% of...
2
by: Todd D. Levy | last post by:
I have a primary table (containing basic contact information) and a number of subsidiary tables (containing various additional information) for employees. Most of the subsidiary tables have a...
3
by: Tee | last post by:
Hi, How to case select with case-insensitive ? eg: Select Case Textbox1.Text Case "Hello" -- ( this will include "Hello", "HELLO", "hElLo" etc etc. ) Case "Bye"
14
by: David Garamond | last post by:
begin; update t set val=val+1; -- 1000 times commit; How many record versions does it create? 1 or 1000? I'm implementing a banner counter which is incremented at least 2-3 millions a day. I...
4
by: sdeg | last post by:
Hi I get the following. Where is the problem? > uname -a Linux ensv00lu 2.4.21-190-smp #1 SMP Tue Feb 10 01:07:03 UTC 2004 i686 unknown > csh case: Too many arguments.
4
by: Deano | last post by:
I have a little search routine going whereby the user types in some text and clicks a button on the main form. I then see if that text exists in a record on the subform. I get a match, grab the...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.