I need a particular select statement.
I am querying a 3rd party database. Sample columns are shown below. As you can see, there are several rows of data for each TRANS_ID. They are using the STRING_VALUE column to store various things, depending on the NAME value.
I need a select statement that does the following--
Within a given TRANS_DATE range,
for each TRANS_ID,
in the case where NAME = 'computed.call_zone' and STRING_VALUE = 'international'
I need to return the following values:
The STRING_VALUE for when NAME = 'item.dialed-number'
and
The STRING_VALUE for when NAME = 'computed.rounded_duration'
TRANS_ID TRANS_DATE AMOUNT NAME STRING_VALUE
---------- -------------- ---------- --------------------------- ----------------
130059 2006-05-01 0.355000 computed.call_zone international
130059 2006-05-01 0.355000 default.product_code Phone
130059 2006-05-01 0.355000 computed.billing_rate NULL
130059 2006-05-01 0.355000 computed.rounded_duration 1.000000
130059 2006-05-01 0.355000 item.dialed-number 0018204706294#
130060 ... etc.
130060 ... etc.
130060 ... etc.
I am querying a 3rd party database. Sample columns are shown below. As you can see, there are several rows of data for each TRANS_ID. They are using the STRING_VALUE column to store various things, depending on the NAME value.
I need a select statement that does the following--
Within a given TRANS_DATE range,
for each TRANS_ID,
in the case where NAME = 'computed.call_zone' and STRING_VALUE = 'international'
I need to return the following values:
The STRING_VALUE for when NAME = 'item.dialed-number'
and
The STRING_VALUE for when NAME = 'computed.rounded_duration'
TRANS_ID TRANS_DATE AMOUNT NAME STRING_VALUE
---------- -------------- ---------- --------------------------- ----------------
130059 2006-05-01 0.355000 computed.call_zone international
130059 2006-05-01 0.355000 default.product_code Phone
130059 2006-05-01 0.355000 computed.billing_rate NULL
130059 2006-05-01 0.355000 computed.rounded_duration 1.000000
130059 2006-05-01 0.355000 item.dialed-number 0018204706294#
130060 ... etc.
130060 ... etc.
130060 ... etc.