请大家帮帮忙 access 问题, Thank you very much!
我有一个独立的 table, called patient infor, it has: first name, last name, DOB, gender and race.
现在我如何 create a field named UIN using expression follow by UIN formula below.
The UIN is a 12 digit number consisting of both letters and numbers. The UIN is created using the following formula:
1st digit: First letter of first name, if unavailable, enter ‘9’
2nd digit: Third letter of first name, if unavailable, enter ‘9’
3rd digit: First letter of last name, if unavailable, enter ‘9’
4th digit: Third letter of last name, if unavailable, enter ‘9’
5th & 6th digits: Month of birth (01 to 12)
7th & 8th digits: Day of birth (01 to 31)
9th & 10th digits: Year of birth (00 to 99), do not use century
11th digit: Gender (Male: 1, Female: 2, Transgender: 3, Unknown: 4)
12th digit: Race/Ethnicity (White/Non Hispanic: 1, Black or African American/Non Hispanic: 2, Hispanic/Latino(a): 3, Asian: 4, Native Hawaiian/Pacific Islander: 5, American Indian or Alaskan Native: 6, Two or more races: 7, Unknown/Unreported: 8
------解决方案--------------------
alter table [patient infor] add column UIN char(12);
update [patient infor]
set UIN= IIF(isnull([first name]),'9',left([first name],1))+
IIF(isnull([first name]),'9',mid([first name],3,1))+
IIF(isnull([last name]),'9',left([last name],1))+
IIF(isnull([last name]),'9',mid([last name],3,1))+
format(DOB,'mmddyy')+
choose(Gender,....)+
choose(race...)