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

  • SEARCH
  • Home
  • 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 5931667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:43:37+00:00 2026-05-22T14:43:37+00:00

I am building a system to send emails and I am needing to go

  • 0

I am building a system to send emails and I am needing to go into the [User] table to retrieve the email to send to, as well as a GUID(uniqueidentifier type) which will be used for unsubscribe purposes.

It is for an ecommerce solution so because anonymous and logged in users can have the same email addresses it creates duplicate entries of emails that need to be distinct in the query.

I am having trouble finding a solution to retrieve the email and the guid but only be distinct on the email. Here is my query so far.

SELECT Email, User_GUID
FROM [User]
WHERE 
    IsActive = 1 AND 
    IsEmailValid = 1 AND
    IsNotActiveBecauseUnsubscribed = 0 AND
    Subscribed = 1
GROUP BY Email, User_GUID
  • 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-22T14:43:38+00:00Added an answer on May 22, 2026 at 2:43 pm
    with cte
    as
    (
        select *, row_number() over (partition by Email order by User_GUID) RowNumber
        from [User]
        where 
            IsActive = 1 and 
            IsEmailValid = 1 and 
            IsNotActiveBecauseUnsubscribed = 0 and 
            Subscribed = 1
    )
    select Email, User_GUID
    from cte
    where RowNumber = 1
    

    or

    select Email, User_GUID
    from
    (
        select *, row_number() over (partition by Email order by User_GUID) RowNumber
        from [User]
        where 
            IsActive = 1 and 
            IsEmailValid = 1 and 
            IsNotActiveBecauseUnsubscribed = 0 and 
            Subscribed = 1
    ) tt
    where RowNumber = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are building an email alert system which needs to send customized emails in
i am building this sms notification system, which will send 10 times free sms
I'm building a simple order system and want to send an email after the
I am building a double-entry accounting system in Rails, which includes: User. Attributes: user_id.
I am building an application which will send out custom emails to end users.
I'm building a simple client-server chat system. The clients send data to the server
I am building a software system, which is using Javascript to display an editable
I spend a good deal of time building an email system for my Rails
I'm building a system that need to collect some user sensitive data via secured
I am building a website that has a system where users can send messages

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.