Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

help on query

511922Nov 5 2006 — edited Nov 10 2006

hi,

SELECT srt.service_request_id, ssr.field_service_rep, srt.TYPE_of_tl, nvl(sum(srt.amount) ,0) T_L_Meals,
                   ssr.report_id
            FROM sop_service_report ssr, sop_travel_living srt
            where srt.type_of_tl is not NULL AND
                  upper(trim(srt.type_of_tl)) IN (SELECT upper(trim(property_description)) FROM sop_property_master
                                 WHERE property_key= 'Meals')    
            and ssr.service_request_id = '200014' AND 
            ssr.service_request_id = srt.service_Request_id(+) AND
            ssr.report_id = srt.report_id(+) AND
            ssr.report_status = 'APPROVED'
            GROUP BY srt.TYPE_of_tl, srt.service_request_id , ssr.field_service_rep, ssr.report_id 


Here for request# 200014 there are two guys (field_service_rep[FSR]) 100 and 101 and out of them 100 has entry for 'Meals' category in sop_travel_living table and 101 does not have any entry for 'Meals' in sop_travel_living table. I want to display sum of amount (T_L_Meals) column in above query as under:

field_service_rep         T_L_Meals
-----------------------------------
100                          20
101                          0 --> as there is not entry for it in sop_travel_living table.

The above query has problem in that it does not return the row with 101 in result. The row with FSR 101 is present in sop_service_report.Rght now its giving..

field_service_rep         T_L_Meals
-----------------------------------
100                          20



Pls help to generate above output..

thx

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2006
Added on Nov 5 2006
36 comments
1,079 views