How to remove duplicates in the query

  • Hi to all,

    This is a query:

    SELECT project_case_id, workflow_projects.parent_project_id, prj1.step_id,

    lvl1.label_text fiscal_year_value

    FROM get_project_case_eform_field('Payment_FISCAL_YEAR', 'ALL', 2, DEFAULT, DEFAULT)prj1

    INNER JOIN gate.steps ON steps.step_id = prj1.step_id

    inner join gate.workflow_projects on workflow_projects.workflow_project_id = prj1.project_case_id

    inner join lookup_values_l lvl1 on lvl1.lookup_value_id = CONVERT(numeric,answer)

    WHERE steps.step_name = 'Payment Request' order by 1

    And this is a result of this query:

    project_case_idparent_project_idstep_idfiscal_year_value

    324322602008-2009

    325321602008-2009

    325323602009-2010

    335334602008-2009

    336334602008-2009

    How to receive only one row for parent_project_id if fiscal_year_values are the same (like this):

    project_case_idparent_project_idstep_idfiscal_year_value

    324322602008-2009

    325321602008-2009

    325323602009-2010

    335334602008-2009

    Please give me idea. I was trying distinct and grouping- I cannot receive desirable result - Thanks!!

  • I have done it by using UNION group by of parent projects with projects.

  • If you eliminate the project_case_id column which causes the rows to differ, you can remove dublicates by grouping other columns as you have done.

    Eralper

    T-SQL Programmer

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply