# How do I add "Date of Birth" to the below query so that I can pull the Date of Birth when I run the query?

**URL:** <https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [June 27, 2017, 10:11am UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634 "2017-06-27T10:11:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![essence.clayton](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@essence.clayton](https://forums.toadworld.com/u/essence.clayton)\
**Post date:** [June 27, 2017, 10:11am UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/1 "2017-06-27T10:11:00Z")

</div>

select to\_char(app\_n) as app\_num, ASGN\_CR\_LIM\_A as climit,  
fnal\_disp\_d as decision\_dt,  
enty\_d as application\_dt,  
to\_char(fnal\_disp\_d,‘yyyy-mm’) as decdt\_yyyy\_mm, fnal\_disp\_d-enty\_d as days\_to\_decision,  
case when stat\_c=‘NEWACCOUNT’ then ‘Approved’  
when stat\_c=‘DECLINE’ then ‘Decline’  
end as app\_decision,  
APPCT\_FICO\_SCOR\_N as applicant\_fico,  
CO\_APPCT\_FICO\_SCOR\_N as co\_applicant\_fico,  
ICOME\_A as Income, DBT\_A, HIGH\_LIM\_A as High\_Limit,  
VERF\_AST\_N, SPND\_NEED\_N,  
RECM\_LINE\_A, CELL\_C, case when cell\_c in (‘CELL 10’,’’) then ‘AUTO’  
else ‘MANUAL’  
end as decision, substr(UBS\_card\_I,13,4) as UBS\_card\_I  
from bank\_owner.ccu\_application\_info where stat\_c in (‘NEWACCOUNT’,‘DECLINE’) and curr\_rec\_f=‘Y’  
and app\_n not in (14005325,14007232,14007045) and (substr(to\_char(ubs\_carD\_i),1,6) is null or substR(to\_char(ubs\_card\_i),1,6) in (‘419742’))  
and fnal\_disp\_d between ‘01-JUNE-2017’ and ‘30-JUNE-2017’

---

<div class="post-metadata">

**Author:** ![GregDavis11009](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gregdavis11009/32/122_2.png) [@GregDavis11009](https://forums.toadworld.com/u/GregDavis11009)\
**Post date:** [June 28, 2017, 3:19pm UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/2 "2017-06-28T15:19:52Z")

</div>

if there is a field containing the date of birth in the table ccu\_application\_info then just add a comma, space and that field name (and optionally a space and an alias name like DOB, DateOfBirth or whatever you want the colmn header name to look like) after the last field in your select clause (the last line above the word from). If applicant demographics (like address, phone, and date of birth) are in a separtate table and all you have is an applicant ID inthe ccu\_application\_info table then you will need a join statement in the from clause to join to that demographics table on the applicant ID (should be a field in both tables) i.e.

from bank\_owner.ccu\_application\_info

join bank\_owner.applicant\_demographics

on bank\_owner.ccu\_application\_info.applicantID = bank\_owner.applicant\_demographics.applicantID.

where …

---

<div class="post-metadata">

**Author:** ![essence.clayton](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@essence.clayton](https://forums.toadworld.com/u/essence.clayton)\
**Post date:** [June 29, 2017, 5:44am UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/3 "2017-06-29T05:44:01Z")

</div>

Hello,

The date of birth in the table ccu\_application\_info is pulling as NULL as it is a column called DATE\_OF\_BIRTH\_NL which I am not sure if it is related to DOB. There is a date of birth column in the table ccu\_customer\_info that doesn’t pull has NULL and this is that data I am looking for. Is there anyway to either change the DATE\_OF\_BIRTH\_NL from pulling as NULL or is there a way that I can pull data of birth column from the table ccu\_customer\_info?

---

<div class="post-metadata">

**Author:** ![InfoMan](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/infoman/32/322_2.png) [@InfoMan](https://forums.toadworld.com/u/InfoMan)\
**Post date:** [June 29, 2017, 7:30am UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/4 "2017-06-29T07:30:50Z")

</div>

The simple answer is that you will need to add the table that contains the desired information into the query by joining to that table.

HOW this is done, i.e., which column(s) to join with, depends on your data model. Your statement of “…I am not sure if it is related to DOB” cause me to think that you need to become more familiar with your data model. You may need to consult with the database administrator and/or the database documentation to determine what would work best.

---

<div class="post-metadata">

**Author:** ![essence.clayton](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@essence.clayton](https://forums.toadworld.com/u/essence.clayton)\
**Post date:** [June 29, 2017, 7:43am UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/5 "2017-06-29T07:43:54Z")

</div>

Thanks for the reply. I agree I do need to become more familiar with the data model that I am working with if I will continue to work with it, unfortunately there is not a database administrator or any database documentation at the company that I work at for this system. The documentation that I did find was through my research from Google was helpful to a degree. I located this website by Google to see if I could locate the help that I was looking for. The script above was given to me by my manager who doesn’t know what it means but wants to pull DOB as part of the script. The person that created this script is no longer with the company.

---

<div class="post-metadata">

**Author:** ![GregDavis11009](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gregdavis11009/32/122_2.png) [@GregDavis11009](https://forums.toadworld.com/u/GregDavis11009)\
**Post date:** [June 29, 2017, 12:02pm UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/6 "2017-06-29T12:02:03Z")

</div>

You can always see what is in a table by selecting top 100 \* from YourTableName (or the Oracle equivalent of top, something like where rownum \<= 100 forgot exact syntax).

Change the from clause in your query to:

from bank\_owner.ccu\_application\_info

join bank\_owner.ccu\_customer\_info

on bank\_owner.ccu\_application\_info. = bank\_owner.ccu\_customer\_info.

The join adds the fields in the ccu\_customeer\_info table, then you can add the date of birth field from that table to the select clause of your query. You may want to alias the table names to make it easier.

Select Cust.DateOfBirth, rest of your App.fields

From bank\_owner.ccu\_application\_info App

join bank\_owner.ccu\_customer\_info Cust

on App. = Cust.

Find your common customer ID by number or alpha number that always matches the customer name.

---

<div class="post-metadata">

**Author:** ![essence.clayton](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@essence.clayton](https://forums.toadworld.com/u/essence.clayton)\
**Post date:** [June 29, 2017, 12:27pm UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/7 "2017-06-29T12:27:57Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![GregDavis11009](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gregdavis11009/32/122_2.png) [@GregDavis11009](https://forums.toadworld.com/u/GregDavis11009)\
**Post date:** [June 29, 2017, 1:28pm UTC](https://forums.toadworld.com/t/how-do-i-add-date-of-birth-to-the-below-query-so-that-i-can-pull-the-date-of-birth-when-i-run-the-query/39634/8 "2017-06-29T13:28:36Z")

</div>

You are welcome. Just paying it back for all the help I got from this forum when I started using Toad. Just wait until you start using Toad Automation (greatest feature of Toad IMHO), there are tutorial videos online to help you get started.

[http://dev.toadforsqlserver.com/TDPVideos/TDPVideo.html](http://dev.toadforsqlserver.com/TDPVideos/TDPVideo.html)
