SpeedThink
MIS
Currently, I am querying a Oracle Database with SQL similar to the following:
select Enc No, Patient No, Contract Id,
from patient_encounter,
where admit_date is ...
The result is as follows:
Enc No Patient No Contract Id
9050068 125682 X59
I then export to Excel and insert two additional columns next to the columns containing Enc No. and Patient No. to obtain modified columns to enter into another query. Note the example below:
Enc No Modified Enc No Patient No Modified Patient No
9050068 9050068, 12568 '0012568',
In essence, I added a comma to the "Enc No" and added single quotes and a comma to the "Patient No." Further, the number of padded zeroes to the "Patient No" will vary. In other words, the "Modified Patient No" must be 7 characters in length. Otherwise, no data is pulled for that patient in the query.
Challenge; I am able to construct an "If Statement" in Excel to perform this. However, due to the large number of analyses and worksheets involved, is there a way to perform this in SQL? VBA?
Thanks in advance!
select Enc No, Patient No, Contract Id,
from patient_encounter,
where admit_date is ...
The result is as follows:
Enc No Patient No Contract Id
9050068 125682 X59
I then export to Excel and insert two additional columns next to the columns containing Enc No. and Patient No. to obtain modified columns to enter into another query. Note the example below:
Enc No Modified Enc No Patient No Modified Patient No
9050068 9050068, 12568 '0012568',
In essence, I added a comma to the "Enc No" and added single quotes and a comma to the "Patient No." Further, the number of padded zeroes to the "Patient No" will vary. In other words, the "Modified Patient No" must be 7 characters in length. Otherwise, no data is pulled for that patient in the query.
Challenge; I am able to construct an "If Statement" in Excel to perform this. However, due to the large number of analyses and worksheets involved, is there a way to perform this in SQL? VBA?
Thanks in advance!