Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creation of dynamic "calculated" column

Status
Not open for further replies.
Aug 30, 2003
41
US
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!

 
I don't know the pecularities of oracle, so pseudo-code:
select Enc No||"," as Enc_No
,"'"||Right("0000000"||Patient No,7)||"'" as Patient_No
, Contract Id
from patient_encounter
where admit_date is ...


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top