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!

Problem with Select Statement

Status
Not open for further replies.

nread

Technical User
Oct 31, 2001
58
GB
Can anyone suggest how i can group by the two categories 'Inbound' & 'Outbound'...?

The select doesn't seem to do this.... Here's an example of the results.......

Grateful for any help....

Inbound 0961 .0012549 .05
Inbound 0961 .0050196 .2
Inbound 0961 .0138039 .55
Inbound 0961 .0100392 .4
Inbound 0961 .0062745 .25
Inbound 0961 .0100392 .4
Inbound 0961 .0058562 .23333333
Inbound 0961 .0033464 .13333333
Inbound 0961 .020915 .83333333
Inbound 0961 .0138039 .55
Inbound 0961 .0079477 .31666667
Inbound 0961 .016732 .66666667
Inbound 0961 .0435032 1.7333333






SELECT
DECODE(rating_profile_no,24,'Outbound','Inbound'),
substr(b_digits,1,4),
sum(cumulative_charge/100),
sum(event_duration/60),
DECODE(event_duration,0,0,((sum(event_duration/60))/(sum(cumulative_charge/100)))),
count(*)
FROM
v_cdrq_&dte1
WHERE
b_digits like '09%'
AND
rating_profile_no in (13,24,60,107,108)
GROUP BY
substr(b_digits,1,4),
event_duration,
DECODE(rating_profile_no,24,'Outbound','Inbound')
 
You might try nesting your query:

SELECT * FROM
(your_original_query here)
GROUP BY inbound_outbound_column;

In order for this to work, you will have to give each item in your SELECT list a column alias:

SELECT DECODE(rating_profile_no,24,'Outbound','Inbound') direction,
substr(b_digits,1,4) b,
sum(cumulative_charge/100) cum_sum,....etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top