Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6828755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:25:12+00:00 2026-05-26T22:25:12+00:00

I am executing the following query, Select distinct a.cr_id, Case When ca.ca_vote = ‘Approve’

  • 0

I am executing the following query,

Select distinct
  a.cr_id,
  Case 
    When ca.ca_vote = 'Approve' and ca.ca_title='MANAGER' Then ca.ca_email
    When ca.ca_vote = 'Reject' Then ''
    When ca.ca_vote = 'Pending' Then ''
    When ca.ca_vote = 'IN PROCESS' Then ''
  End as ca_email
from
  credit a
  inner join credit_approvals ca on ca.c_id=a.cr_id
where 
  a.cr_cs_date between Convert(varchar(20),'11/16/2011',101) and dateadd(day,1,convert  (varchar(20),'11/16/2011',101))
order by
  a.cr_id

Despite distinct for cr_id, it is still displaying the duplicate values. Please let me know how to handle this, so that I could able to display only distinct records.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:25:13+00:00Added an answer on May 26, 2026 at 10:25 pm

    Distinct is applied to all columns, not the one which is immediately after Distinct.

    If you have several different ca_email for a cr_id, you will see them all.

    If you don’t want that, you have to come up with a rule to decide what record among the duplicates must stay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am executing a following query: SELECT DISTINCT users.user_id, users.email, users.irc_nickname FROM users, user_group_map,
I'm executing the following query: Select guiPolygonID, dbo.fn_Yval(p1X, p1Y, p2X, p2Y, 4.003318) From [vPolygonSegments]
When executing the following (complete) SQL query on Microsoft SQL Server 2000: SELECT B.ARTIFACTTNS,
I'm executing the following query SELECT COUNT(*) FROM table WHERE field1='value' AND (field2 >=
I would like to perform the following query in HQL: select count(distinct year(foo.date)) from
I have the following SQL query: SELECT DISTINCT business_key FROM Memory WHERE concept <>
while executing the following query, i get an error that there's an error in
I am successfully executing the following query in SQL Server 2008 built into VS2008:
How would I go about executing the following Hibernate query using the criteria API.
I am getting Incorrect syntax near the keyword 'select' after executing the following code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.