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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a challenging SELECT statement

Status
Not open for further replies.

hapax

Programmer
Nov 10, 2006
105
0
0
US
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.
 
Never mind. I figured it out using some subselects
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top