If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > need sql query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-03-05, 10:58
Nura Nura is offline
Registered User
 
Join Date: Oct 2005
Posts: 21
need sql query

Hi

i have 2 tables
the query that i have written is

select distinct mm.subscriber_id,count(mh.seq_memb_id),mm.PREV_SUB SCRIBER_ID,mm.subscriber_id,mm.DATE_OF_BIRTH,mm.ge nder,decode(mh.elig_status,'Y','YES'),decode(mh.el ig_status,'N','NO')
from hsd_member_master mm,hsd_member_elig_history mh
where mm.seq_memb_id = mh.seq_memb_id
and mm.seq_memb_id in (20621,20622,20623)
group by mm.subscriber_id,mh.seq_memb_id,mm.PREV_SUBSCRIBER _ID,mm.subscriber_id,mm.DATE_OF_BIRTH,mm.gender,mh .elig_status

my result should be
subscriber_id,PREV_SUBSCRIBER_ID,DATE_OF_BIRTH,gen der,no of 'yes' in elig_status,no of 'no' in hsd_member_elig_history.


there is multiple rows for each seq_memb_id in eli
Reply With Quote
  #2 (permalink)  
Old 10-03-05, 11:14
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool


Do not use DISTINCT with GROUP BY
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 10-03-05, 11:32
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Hi

You are grouping by mh.seq_memb_id but it is not contained in the select clause (except as part of an aggregate function). This looks like a likely candidate for your problem

HTH
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On