×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need a challenging SELECT statement

Need a challenging SELECT statement

Need a challenging SELECT statement

(OP)
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.
Replies continue below

Recommended for you

RE: Need a challenging SELECT statement

(OP)
Never mind. I figured it out using some subselects

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close