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 6072451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:09:43+00:00 2026-05-23T10:09:43+00:00

Got exactly the same question as i asked before: sql take one out from

  • 0

Got exactly the same question as i asked before: sql take one out from the list 🙂 but i cant integrate the

CPA.WANT_EMAIL = 1

instead of

AND CPA.PARTNER_ID = CCD.PARTNER_ID AND CCD.SITE_DOMAIN = 'www.projedepo.com')

i mean want_email is also from COMPANY_PARTNER CPAeverything is the same, except, site_domain is needed to be exactly the same as http://www.projedepo.com but for want_email, i need just the negative, 0 or positive 1, the formats of values are different.

how do i do it? thx for help everyone!

Here is the code for now:

<cfquery name="GET_POT_COMPANY" datasource="#DSN#">
    SELECT
        C.COMPANY_ID,
        C.MEMBER_CODE,
        C.FULLNAME,
        C.PARTNER_ID,
        C.RECORD_DATE,
        CC.COMPANYCAT
          <cfif isdefined('attributes.report_sort2')
            and attributes.report_sort2 is 1>
            , 'www.projedepo.com' AS SITE_DOMAIN
          </cfif>
    FROM 
        COMPANY C, 
        COMPANY_CAT CC
    WHERE
          C.COMPANYCAT_ID = #attributes.comp_cat# 
      AND CC.COMPANYCAT_ID = C.COMPANYCAT_ID
        <cfif isdefined('attributes.report_sort2')
          and attributes.report_sort2 is 1>
          AND EXISTS
            ( SELECT *
              FROM
                COMPANY_CONSUMER_DOMAINS CCD,
                COMPANY_PARTNER CPA
              WHERE C.COMPANY_ID = CPA.COMPANY_ID
                AND CPA.PARTNER_ID = CCD.PARTNER_ID
                AND CCD.SITE_DOMAIN = 'www.projedepo.com'
            )
        </cfif>
    ORDER BY 
        C.RECORD_DATE DESC
</cfquery>

this is the previous example, the working one, all i need is to change the AND CPA.PARTNER_ID = CCD.PARTNER_ID AND CCD.SITE_DOMAIN = 'www.projedepo.com'

to CPA.WANT_EMAIL = 1

  • 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-23T10:09:44+00:00Added an answer on May 23, 2026 at 10:09 am

    Will this work for you:

    . . .
          AND EXISTS
            ( SELECT *
              FROM
                COMPANY_PARTNER CPA
              WHERE C.COMPANY_ID = CPA.COMPANY_ID
                AND CPA.WANT_EMAIL = 1
            )
    . . .
    

    ?

    That is, just replace the existing EXISTS subquery with this one.


    UPDATE

    Looks like a different approach is needed here. Try this:

    <cfquery name="GET_POT_COMPANY" datasource="#DSN#">
        SELECT
            C.COMPANY_ID,
            C.MEMBER_CODE,
            C.FULLNAME,
            C.PARTNER_ID,
            C.RECORD_DATE,
            CC.COMPANYCAT
              <cfif isdefined('attributes.report_sort2')
                and attributes.report_sort2 is 1>
                , COALESCE(CPA.WANT_EMAIL, 0) AS WANT_EMAIL
              </cfif>
        FROM 
            COMPANY C
            INNER JOIN COMPANY_CAT CC ON CC.COMPANYCAT_ID = C.COMPANYCAT_ID
             <cfif isdefined('attributes.report_sort2')
              and attributes.report_sort2 is 1>
            LEFT JOIN (
                SELECT
                    COMPANY_ID,
                    MAX(CAST(WANT_EMAIL AS int)) AS WANT_EMAIL
                FROM
                    COMPANY_PARTNER CPA
                GROUP BY COMPANY_ID
            ) CPA ON C.COMPANY_ID = CPA.COMPANY_ID
            </cfif>
        WHERE
            C.COMPANYCAT_ID = #attributes.comp_cat# 
        ORDER BY 
            C.RECORD_DATE DESC
    </cfquery>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a bluescreen in windows while cloning a mercurial repository. After reboot, I now
got a new blog at wordpress few days ago ( http://ghads.wordpress.com ) and I
Got a class that serializes into xml with XMLEncoder nicely with all the variables
Got myself in a bit of a pickle here ... working on a CMS
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
Got a bit of a mind freeze at the moment. I have the following
I got into a mini-argument with my boss recently regarding project failure. After three
I got a webserver with a running application. There's a webpage with a form:
I got this error today when trying to open a Visual Studio 2008 project
I got this output when running sudo cpan Scalar::Util::Numeric jmm@freekbox:~/bfwsandbox/sa/angel/astroportal/dtu8e/resources$ sudo cpan Scalar::Util::Numeric [sudo]

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.