Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

oracle query

Posted on 2013-06-07
8
Medium Priority
?
317 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 1000 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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 49

Expert Comment

by:PortletPaul
ID: 39231180
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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 shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

705 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