Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old June 28th, 2004, 11:23 AM
thordiddy thordiddy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 40 thordiddy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 17 m 12 sec
Reputation Power: 5
Talking Question about DISTINCT

I have a script that stores 3 values, email, firstname and lastname in a cursor. The only problem is that it often returns many of the same values due to multiple entries in the database tables I am searching. I tried distinct, but every time the script runs I get an "ORA-01847: day of month must be between 1 and last day of month GHID". When I take out distinct the program runs fine.

Here is my code:

NOW:=SYSDATE;
BEFORE:=NOW - 7;
OPEN output_cur FOR
SELECT
DISTINCT(ME.e_mail),
su.pat_firstname,
su.pat_lastname
FROM
ops_arw.member_pin ME,
ops_arw.subscriber SU,
ops_arw.int_med_claim_summary INT
WHERE
ME.SRV_EMAIL_PREFERENCE ='Y' AND
ME.CERT_NO =SU.CERT_NO AND
ME.CERT_NO =INT.CERT_NO AND
TO_CHAR(TO_DATE(SU.MEM_DOB, 'YYYYMMDD'), 'YYYYMM')=TO_CHAR(ME.MEM_DOB, 'YYYYMM') AND
INT.INSERT_DATE >= BEFORE;


Thanks for the help.

Reply With Quote
  #2  
Old June 28th, 2004, 03:22 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
replace
Code:
TO_CHAR(TO_DATE(SU.MEM_DOB, 'YYYYMMDD'), 'YYYYMM')=TO_CHAR(ME.MEM_DOB, 'YYYYMM') AND


with
Code:
TRUNC(SU.MEM_DOB) = TRUNC(ME.MEM_DOB) AND

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Question about DISTINCT


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway