Solved

oracle query

Posted on 2013-06-07
8
315 Views
Last Modified: 2013-06-08
select dn.donor_id,
         salutation,
         first_name,
         middle_name,
         last_name,
         description,
         coll_date,
         life_donations,
         life_donations/8 as mile_stone
  from donations@pdon_new d,
           donors@pdon_new dn,
         master_codes mc
 where d.donor_id = dn.donor_id
   and unit_id is not null
   and mc.udf1 = blood_type
   and mc.code_type = 'ABO'
   and coll_date = ' 31-may-2013'

My question is - I divide life_donations by 8 to see who has reached a gallon mile. In my report I wasnt to show the remainder as 0 so when I divide life_donations by 8 I need to show 0 and only those have to be on the report.
life-donations.xls
0
Comment
Question by:anumoses
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 41

Expert Comment

by:Sharath
ID: 39229769
Do you want to truncate the fration part?
select dn.donor_id,
         salutation,
         first_name,
         middle_name,
         last_name,
         description,
         coll_date,
         life_donations,
         trunc(life_donations/8) as mile_stone
  from donations@pdon_new d,
           donors@pdon_new dn,
         master_codes mc
 where d.donor_id = dn.donor_id
   and unit_id is not null
   and mc.udf1 = blood_type 
   and mc.code_type = 'ABO'
   and coll_date = ' 31-may-2013'

Open in new window

0
 
LVL 41

Accepted Solution

by:
Sharath earned 250 total points
ID: 39229774
Not sure if I understand the question correctly, but if you want to see only those life donations that can be devided by 8 with reminder 0, you can add additional filter.
select dn.donor_id,
         salutation,
         first_name,
         middle_name,
         last_name,
         description,
         coll_date,
         life_donations,
         trunc(life_donations/8) as mile_stone
  from donations@pdon_new d,
           donors@pdon_new dn,
         master_codes mc
 where d.donor_id = dn.donor_id
   and unit_id is not null
   and mc.udf1 = blood_type 
   and mc.code_type = 'ABO'
   and coll_date = ' 31-may-2013'
   and reminder(life_donations,8) = 0

Open in new window

0
 
LVL 6

Author Comment

by:anumoses
ID: 39229816
Is remainder 10G?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 41

Expert Comment

by:Sharath
ID: 39229846
Yes
0
 
LVL 41

Expert Comment

by:Sharath
ID: 39229850
typo.
select dn.donor_id,
         salutation,
         first_name,
         middle_name,
         last_name,
         description,
         coll_date,
         life_donations,
         trunc(life_donations/8) as mile_stone
  from donations@pdon_new d,
           donors@pdon_new dn,
         master_codes mc
 where d.donor_id = dn.donor_id
   and unit_id is not null
   and mc.udf1 = blood_type 
   and mc.code_type = 'ABO'
   and coll_date = ' 31-may-2013'
   and remainder(life_donations,8) = 0

Open in new window

0
 
LVL 23

Expert Comment

by:David
ID: 39229936
i can't add to the author's query, but the typo in line 17 above is bothersome.  Unless all column entries have a leading space and a lower-case month, you are going to need a conversion function.  Assuming that coll_date (LOVE the abbreviation) is datatype DATE, then the comparison should be rewritten as ...coll_date = TO_DATE('31-MAY-2013','DD-MON-YY').
0
 
LVL 6

Author Closing Comment

by:anumoses
ID: 39229976
thanks
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 39231180
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Database Design Dilemma 6 71
Oracle 12c Default Isolation Level 17 64
Need help on decision table structure 7 58
Oracle Errors 11 89
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question