Duplicate Values:(

Results 1 to 2 of 2

Thread: Duplicate Values:(

  1. #1
    Join Date
    Dec 1969

    Default Duplicate Values:(

    Hi Friends,<BR><BR>I am using this query to display Project_ID,CLIENT_DIV,.ECONOMIC_BUYER,CONTACT_NAME ,STRATEGIC_IMP. They I am getting records properly few ids are duplicated as there will be more than one record in Proj_details table.<BR><BR>I need to display record only once. Can anyone help me in this regard<BR><BR><BR>Here is the table structure for Project_master(Project_id,Project_title,MoU_Confir med,------) and Proj_details(Project_id,----,Country_id)<BR><BR><BR>select distinct P.PROJECT_ID,R.REGION_NAME,CD.CLIENT_DIV,S.S_DESCR IPTION,P.ECONOMIC_BUYER,P.FY,P.CONTACT_NAME,(CASE P.MOU_CONFIRMED WHEN 1 THEN &#039;Yes&#039; WHEN 2 THEN &#039;No&#039; WHEN 3 THEN &#039;Not Required&#039; END),cm.country_name,P.STRATEGIC_IMP FROM PROJECT_MASTER P,PROJ_DETAILS PD,REGION_MASTER R,CLIENT_TYPE CT,CLIENT_DIV CD,BUSINESS B,segment_master s,COUNTRY_MASTER CM WHERE p.seg_id=s.seg_id and P.REGION_ID=R.REGION_ID AND P.CLIENT_TYPE_ID=CT.CLIENT_TYPE_ID and P.CLIENT_DIV_ID=CD.CLIENT_DIV_ID AND B.BUSINESS_ID=P.BUSINESS_ID AND P.PROJECT_ID=PD.PROJECT_ID AND PD.COUNTRY_ID=CM.COUNTRY_ID and P.MASK=0 Group by p.Project_id,R.REGION_NAME,CD.CLIENT_DIV,S.S_DESCR IPTION,P.ECONOMIC_BUYER,P.FY,P.CONTACT_NAME,P.STRA TEGIC_IMP,P.MOU_CONFIRMED,CM.COUNTRY_NAME <BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Duplicate Values:(

    If the duplicates are coming from multiple entries in the Proj_Details table, then the only item in the SELECT that is different between the duplicates will be CM.Country_Name. It is up to you how you handle this:<BR><BR>-you could take this item out of the SELECT list so that the DISTINCT does its job (you can also remove the GROUP BY as it does nothing here)<BR><BR>-if you need the country name in the list then you have to use an aggregate function, such as MAX or MIN so that only one country is displayed. In this case you can remove the DISTINCT and remove CM.Country_Name from the GROUP BY<BR><BR>If neither of these are good enough try giving a specific example of what you want with data.<BR><BR>Gavin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts