Query MySQL or the CF code to 'Flag' a group of results from a query based on a common value?

I have the following query that examines customer accounts:

SELECT    ACCOUNT_ID, SUBSCRIBER_ID, PKG_CODE    
FROM   Accounts   
WHERE  ACCOUNT_DESC LIKE '%Eye%'   
GROUP BY  ACCOUNT_ID

Gives me the following result...

 1. ACCOUNT_ID,  SUBSCRIBER_ID, PKG_CODE  
2. ---------- -------------- -------   
3. 11016869,    10016598,      N 
4. 11015922,    10015713,      N 
5. 11015062,    10014878,      N 
6. 11018312,    10017973,      Y 
7. 11018310,    10017973,      N 
8. 11018309,    10017973,      N 
9. 11018308,    10017973,      N

Question: How can I display a '1' in a column of flag if 'someone' of the 'SUBSCRIBER_ID' have a "O" value in the PKG_CODE column?

Here are the results of the query that I'm trying to do for this example (note that the last 4 reviews should be marked with a '1' because one of them had a 'Y' for PKG_CODE and SUBSCRIBER_ID correspondent...)

  1. ACCOUNT_ID, SUBSCRIBER_ID, PKG_CODE, FLAG
  2. ---------- -------------- ------- -----
  3. 11016869,10016598, N
  4. 11015922,10015713, N
  5. 11015062,10014878, N
  6. 11018312,10017973, Y, 1
  7. 11018310,10017973, N-1
  8. 11018309,10017973, N-1
  9. 11018308,10017973, N-1

I tried the following, but it only reports the recordings of 'Y '? I need to check also the SUBSCRIBER_ID' column value...

SELECT    ACCOUNT_ID, SUBSCRIBER_ID, PKG_CODE  
, IF(PKG_CODE = 'Y', "Y", "N") AS FLAG   
FROM   Accounts   
WHERE  ACCOUNT_DESC LIKE '%Eye%'   
GROUP BY  ACCOUNT_ID

If this can be done on the page of the CF, which would work as well instead of in the query... I just need the Flagged values to display next to each record.

SELECT ACCOUNT_ID, SUBSCRIBER_ID, PKG_CODE, IF(SUBSCRIBER_ID IN)

(SELECT SUBSCRIBER_ID

Accounts

WHERE ACCOUNT_DESC LIKE '% eyes %' AND PKG_CODE = 'Y'), 1, 0) AS flag

Accounts

WHERE ACCOUNT_DESC LIKE '% % eyes '.

ACCOUNT_ID GROUP

Tags: ColdFusion

Similar Questions

  • is shaded a d I canProblems installation of windows to date get the error code 80070490, tried to install windows vista from DVD upgrade areanot upgrade I can do?

    Windows update installation problems get code error 80070490, tried to install windows vista from DVD of the upgrade box is greyed out and I can't upgrade, any advise?

    Hi, Eve,.

    First run the preparation tool system update for your version of Windows.

    Start > right click on computer

    Select Properties

    Under system > Type system, you will see the 32 - bit or 64-bit system

    Download the tool for your system (x 86 is 32-bit, x 64 is 64-bit)

    http://support.Microsoft.com/kb/947821

    When finished, restart the update.  If the update fails, you will need to repair Windows.

    Your DVD says recovery?  This is the DVD, you will need to reinstall or repair Windows.

    What is the make and model of your computer.  The manufacturers provide a Recovery Utility in many cases.

    Ex: HP provides a Recovery Manager for their computers

    It is found by clicking Start > all programs > PC Help & Tools

    Click on Recovery Manager

    Follow the prompts on the screen to repair your computer

    How to automatically repair Vista using Startup Repair

    http://www.bleepingcomputer.com/tutorials/repair-Windows-with-Windows-Startup-Repair/

  • I get the error code 7 when you try to upgrade from Photoshop or even download a previous. Current issues are:

    What can I do about it?

    Exit code: 7

    Please see specific errors below for troubleshooting. For example, ERROR: DF024...

    -------------------------------------- Summary --------------------------------------

    -0 fatal Error (s), 2 error (s)

    -Payload: camera profiles Installer 8.0.0.0 {56DCC6F4-322E-42DA-A5DA-26BAD28C1E10}.

    ERROR: DF024: unable to preserve the original file at "/ Library/Application Support/Adobe/CameraRaw/LensProfiles/1.0/Sigma/Sony/SONY (Sigma_50-200mm_F4 - 5.6_DC_OS_HSM)-RAW.lcp ' (Seq 1713)

    -Payload: Adobe Photoshop CC 2015 support 16.0.0.0 {3FB7A108-368A-4849-A3F3-69571BAAC457}.

    ERROR: DF024: unable to preserve the original file at "/ Library/Application Support/Adobe/Color/Profiles / AnimePalette.icc" (Seq 2)

    -------------------------------------------------------------------------------------

    It is the second set of error codes when you try to upgrade to PS15. The first was code 42. I renamed the files, but it did not work.

    Jim VorwoldtError

    You can also view this document:

    Exit code: 6, Exit Code: 7 Installation error - http://helpx.adobe.com/creative-suite/kb/errors-exit-code-6-exit.html

  • Trying to get Windows updates, get the error code 80004005

    I can't upgrade my pc to windows updates... it seems to download but when the pc reboots it comes up saying failure and makes me again with the same result... It continues to flow upward with the error code 80004005, but cannot find a result or information on this code or what to do to solve this problem... any suggestions?

    * original title - I get the error 80004005 When trying to get updates... my computer updates not for some unknown reason and I can't find what this code means and what to do to fix it... Please help *.

    How to ask a question
    http://support.Microsoft.com/kb/555375 >

    It helps those answering questions if you provide:

    what the version of windows (32-bit or 64-bit) and service pack level.

    you use what browser (exact version).

    what application anti-virus or security suite is installed and your current subscription?

    What third-party firewall

    What anti-malware software can be installed.

    What updates you trying to install? (Number of KB)

    What error do you get everything when trying to install updates?

    Please do it in your next reply.

    You may receive error code 0 x 80004005 and other error codes when you try to start a Windows XP-based http://support.microsoft.com/kb/914232computer >

    Error code 0x80004005

    This problem may occur if a file that requires product Activation Windows (WPA) is damaged or missing. This problem occurs if one or both of the following conditions are met:

    A third-party backup utility or an antivirus program interferes with the installation of Windows XP.

    A file that requires a WPA is changed manually.

    Try manually download and install the update problem - http://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB935509>

  • Mysterious < br > tag in live code, and not in the source code

    I have a problem here, as mentioned above, with ma page Web.  When you go to this link:

    www.tsohngyun.com

    you will find a space perfectly size between menu horizontal blue and red background that lines on two images (image of the handshake, 'Welcome to the Master Insurance Agency' image).  When I look at to inspect the Web site in Dreamweaver in live code, I noticed a < br > tag sitting just before the tag of table containing the red background.  However, when I go back to the source code, the < br > tag is not found by the opening table tag.

    How can I change something that is not in the source code?  I want to get rid of this gap! Help, please!

    And this
    tag does not exist in the source code of your Dreamweaver? Really?  Because it is based on what I see in your code, you
    Tags on line 31, line 35, line 42, line 45 and 49 of your code line.

    Dreamweaver in code and design split view and see if you can spot the
    tags in your code (can even use useful tool to search and replace in Dreamweaver to find each istance of the)
    tag in your code.) Now, not all of the
    the tags are innapropriate so don't remove them just good willy nilly.

    In any case, hope this helps.

  • Y at - it an easy way to get the sql code that is sent in the query UPDATE

    I have a request to UPDATE abbreviated for readability. Is there an easy way to get the sql code that is sent? I use get this info for sql select in the display of debugging in cfeclipse but not for the UPDATE.

    < cfquery debug = "" name = "q" datasource = "#datasource #" > "



    UPDATE [BookingSystem]. [dbo]. [tbTrades]
    SET
    [Status] = #MATCHED_STATUS #.
    WHERE

    clientID = < cfqueryparam value = "" #arguments.clientID # "cfsqltype ="cf_sql_integer"> AND"

    < / cfquery >

    It might pay to read the docs for - http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_17.html#1102316 - focusing on the RESULT parameter.

    Read also about debugging in CF: http://livedocs.adobe.com/coldfusion/8/htmldocs/Debug_01.html

    --

    Adam

  • How can I update the data in mysql using the button defined in the table?

    Hello

    right now I am doing my project for the online election system using dreamweaver cc14. I create a table using php code to bind the data to mysql, and in this painting, I create also a button "vote" for voters to vote. My question is, how can I update my polling data in the mysql database when voters push button "vote" based on the id of the candidates? Here is my code I try:

    <form method="post" id="form1">
          <?php
    $servername = "localhost";
    $username = "root";
    $password = "pass";
    $dbname = "ses";
    
    
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
         die("Connection failed: " . $conn->connect_error);
    } 
    
    
    $sql = "SELECT No, Calon, ID, Jurusan, Image FROM candidates";
    $result = $conn->query($sql);
    
    
    if ($result->num_rows > 0) {
         echo "<table >
      <tr>
      <th>NO</th>
      <th>Candidate</th>
      <th>INFO</th>
      <th>Vote</th>
      </tr>";
         // output data of each row
         while($row = $result->fetch_assoc()) {
             echo "<tr>
      <td>" . $row["No"]. "</td>
      <td><img src=" . $row['Image'] . "></td>
      <td><br/>-" . $row["Calon"]. " <br/>-" . $row["ID"]. " <br/>-" . $row["Jurusan"]. "<br/></td>
      <td><input type="."submit"." name=".$row["Calon"]." id=".$row["No"]. " value="."Vote"."></td>
    
      </tr>";
      if(isset($_POST["".$row['No'].""])){
    
      $vote_sachin = "UPDATE candidates SET Undi=Undi+1 WHERE No=".$row["No"]. "";
    
      $run_sachin = mysqli_query($conn, $vote_sachin);
    
    
    }
        }
      echo "</table>";
    } else {
         echo "0 results";
    }
    
    
    
    
    
    
    $conn->close();
    ?>
    
    
    
    
        </form>
    

    I hope someone can help me in this area, because I'm still new in this programming language.

    Thank you.

    Youre probably going to insert a 'radio button' next to the names of candidates and recover the database ID of that (I guess that the ID is the primary key in your database that uniquely identifies each record.

    His great confusion because you seem to update the database to aid WHERE no = "." $row ["no"]. so I don't know that ID is the primary key?

    IF "No" IS your master database key, you need to change the code below:

    TO:

    Here's the complete code based on the ID of your primary database key.

    <>

    $servername = "localhost";

    $username = 'root ';

    $password = "pass";

    $dbname = 'his ';

    Create the connection

    $conn = new mysqli ($dbname, $servername, $username, $password);

    Check the connection

    If {($conn-> connect_error)

    Die ("connection failed:".) $conn-> connect_error);

    }

    $sql = "SELECT No, Calon, ID, Jurusan, Image OF candidates";

    $result = $conn-> Query;

    If you click on the button "vote" form run the code to update the database below

    {if (isset($_POST['vote']))}

    Get the value of the ID of the radio button form field and store it in a table.

    $update_vote = $_POST ['candidate_id'];

    loop in the table and update the database

    foreach ($update_vote as $value) {}

    $vote_sachin = ' candidates UPDATE SET Undi = Undi + 1 WHERE ID = ".". " $value. » « ;"

    $run_sachin = mysqli_query ($conn, $vote_sachin);

    }

    }

    ?>

    <>

    If ($result-> num_rows > 0) {}

    ECHO '.

    ";

    each line output

    While ($row = {$result-> fetch_assoc())}

    ECHO '.

    ";

    }

    ECHO '.

    ";

    ECHO '.

    NO. Candidate INFO To the vote
    " . $row ["no"]. "
    -" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ["Jurusan"]. "
    ";

    } else {}

    echo "0 results."

    }

    $conn-> close();

    ?>

  • How to insert image from mysql into the table using php and create the checkbox in the table?

    How can I insert image from mysql into the table using php and create the checkbox for each data as a vote? Here is my code...

    WELCOME

    connect_error) {die ("connection failed:".)} $conn-> connect_error); } $sql = "SELECT no, Calon, ID, of course, the Image OF THE candidates." $result = $conn-> Query; If ($resultat-> num_rows > 0) {echo ' '; export data of each line while ($row = $result-> fetch_assoc()) {"echo"}}
    NO Candidate INFO Vote
    " . $row ["no"]. "-" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ['class']. "
    "; } ECHO ' ' ;} else {echo '0 results' ;} $conn-> close();?} >

    hope someone can help me because I am a newbie in this program... need to finish this project... Thank you.

    If you have saved the file name in the database, it's pretty simple.

    echo '' . $row['description'] . '';
    

    Is the same for the box:

    echo '';
    

    If you have saved the image file in the database, it is much more complicated. I recommend you store only the file name in the database.

  • When you install an automatic update. I received the error code 652. try three times. Always code error 652. She strives to update of Miscrosoft Silverlight (KB2164913) need help.

    When you install an automatic update. I received the error code 652. Have tried three times, always the error code 652. She tries to Miscrosoft Silverlight Update. need help

    Hello

    ·        Remember to make changes to the system?

    Follow the steps mentioned below.

    Step 1:

    There may be some third-party software that runs in the background, I suggest you do a clean boot and check. To perform a clean boot follow the steps mentioned in the link given below.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Note: Once you have finished installing, follow step 7 to start the computer in normal startup.

    Step 2:

    Reset windows update components and check. Follow the steps mentioned in the article below.

    How to reset the Windows Update components?

    http://support.Microsoft.com/kb/971058/en-us

    Step 3:

    See the article mentioned below.

    Description of the update for Silverlight: September 1, 2010

    http://support.Microsoft.com/kb/2164913

    To get help after your query in the Microsoft Silverlight Forums. Click on the link below.

    http://forums.Silverlight.NET/forums/

    Thanks and regards.

    Thahaseena M
    Microsoft Answers Support Engineer.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How can I configure xbox 360 on windows XP, all instructions are for Media Center which I did not and asks the key code.

    Windows XP and using the Xbox 360!

    How can I configure xbox 360 on windows XP, all instructions are for Media Center which I did not and asks the key code.  I don't have media player. I received a key to the xbox code, BUT Media Player do not ask for it? My wireless works fine.  XBox works very well. Yes, I know that I should upgrade to Windows 7 but until my budget allows, is what I have.  Thank you.

    Try this link for XBox: http://social.msdn.microsoft.com/Search/en-US?query=XBOX%20on%20Windows%20XP&ac=3

  • How to repair or reinstall the msi engine also what is the error code 2352

    I have problems when I try to download an update for my AVG security program.  It shows a number OXC0070643, MSI engine failure and the error code from 2352.  Any help is requested as the Microsoft site does not appear.

    Hi JohnThelma,

    1. Did you the latest changes on the computer?
    2. You receive error messages when updating security software AVG on the computer?

    The MSI engine is related to the Windows service installed on the computer, I would say that you the article below and try the steps mentioned, check if it helps.

    Problems installing and uninstalling programs on Windows computers

    http://support.Microsoft.com/kb/2438651

    If the previous step fails then I would suggest that you post your query in the AVG forums for assistance.

    Installation error Code OXC0070643         

    http://forums.Avg.com/ww-en/AVG-forums

  • How to download the app and extract the brother .cod files that it contained by program

    Hello

    I want to download and install a new version of my application programmatically.  I read the messages where all the .cod files application including .sibling .cod files are downloaded separately.  Is it possible to simply download the application file, for example Main.cod and extract all the brother .cod files contained (hand - 1.cod, hand - 2.cod)?

    Thank you

    Not sure that understand this issue.  Given that you have already unpacked all the brothers and sisters, then you know how at the server level and can provide information, your application can query.  Your application can read the jad file, or as the naming convention is well known, your application could try to get cod files with a suffix growing until it breaks.  Is that what you were asking?

  • Generated JAD file lists the strange COD files

    I use BB JDE 6.0.0. and it generates a JAD file for the project. The problem is that it lists the COD files, which are not used. I pasted the contents of the JAD file below. COD generated file is AstralEffects.cod, but there is no file AstralEffects - 1.cod or AstralEffects - 2.cod.

    How can I remove these COD files are not used in the JAD file? I tried to remove them manually, but then I got ' 907 invalid COD: impossible to import the ZIP file. I'm trying to find a way to change the JAD of BB JDE 6.0.0 file, but I can't find an option like that. So, how can I change the generated JAD file?

    Manifest-Version: 1.0
    MIDlet-Version: 2.2
    MIDlet-Jar-Size: 171299
    RIM-COD-URL-2: AstralEffects - 2.cod
    Microedition-Configuration: CLDC-1. 1
    MIDlet-Jar-URL: AstralEffects.jar
    RIM-COD-Module-dependencies: net_rim_cldc
    RIM-COD-SHA1-2: ed 81 41 47 32 BA 7f b7 9 d 6a e6 78 83 e9 ff 71 83 11 a9
    RIM-COD-URL-1: AstralEffects - 1.cod
    RIM-COD-SHA1-1: 04 25 03 50 FF e8 4 b d6 63 77 12 d8 f1 7f 67 60 85 6 9th 2f d
    RIM-COD-size-2: 42088
    RIM-MIDlet-flags-1: 0
    RIM-COD-size-1: 48192
    RIM-COD-Module-name: AstralEffects
    MIDlet-name: AstralEffects
    RIM-COD-size: 71800
    RIM-COD-creation-Time: 1291403520
    MIDlet-1: AstralEffects, AstralEffects.png, AstralEffects
    RIM-COD-URL: AstralEffects.cod
    RIM-COD-SHA1: 31 34 46 79 8 7f c2 d 2B f7 19 98 c0 f6 bb 03 c3 2 df c 78 c0
    Microedition-profile: MIDP-2. 0
    MIDlet-vendor: mobile visuals

    Once you rename the original to the extension ZIP and unzip, ther original COD there not more, right? You should deploy all of the files that I unzipped from the aggragate COD.

  • A fatal error occurred when attempting to access the SSL server credential private key. The error code returned from the cryptographic module is 0x8009030D. The internal error state is 10001.

    Hello

    I just bought an HP computer, Windows 8 Pro, x64bit. I worked OK for a week and then started to freeze. It freezes all the time. I'll send the error message in the event log. I'd appreciate your help because I've had enough of this gel and I turn it works all the time.

    Log name: System
    Source: Schannel
    Date: 12/07/2013-12:55:12
    Event ID: 36870
    Task category: no
    Level: error
    Keywords:
    User: SYSTEM
    Computer: Aleksey
    Description:
    A fatal error occurred when attempting to access the SSL server credential private key. The error code returned from the cryptographic module is 0x8009030D. The internal error state is 10001.
    The event XML:
    http://schemas.Microsoft.com/win/2004/08/events/event">
     
       
        36870
        0
        2
        0
        0
        0 x 8000000000000000
       
        7179
       
       
        System
        Aleksey
       
     

     
        Server
        0x8009030d
        10001
     

    Thank you

    Hi Aleksey,

    I appreciate the efforts that you put to publish the query on this forum.

    Please help me with the following information about this issue:

    (1) is the computer that is connected to a domain network?

    (2) when exactly you receive the error message? It is by accessing any application?

    If the computer is connected to a domain network, I suggest you send the request on 8 Windows IT Pro. Check out the link:

    http://social.technet.Microsoft.com/forums/Windows/en-us/home?category=w8itpro

    Please let us know if the computer is not in a domain. We will be happy to help you come.

  • The button code will not replace the stop code

    Hello

    I have been stuck for days trying to figure this out and would appreciate any help offered.

    In an HTML5 document, I use excerpts of code (HTML5) to make an animation stops at some of the images in the scenario and then buttons take the Viewer to specific sections of the timeline.

    Displaying image002.pngDisplaying image004.pngDisplaying image006.png

    The Start button must essentially ignore the playback head on a structure ahead of the frame with the code to stop... but it doesn't. When I preview the video, I can click on the button, but the playhead does not advance the flag "getgoing. I tried this with both specific chassis numbers, but that no longer works.

    I did test files containing a single button and the stop code and everything works fine. But in this file larger with several going on, the buttons stop working. Certainly, I have imported image sequences that I made in After Effects (my favorite animation software) and Animate takes more time to save and preview because of this. I don't know if the mere fact of having sequences of images as graphic symbols would change the functionality of a button, but I'm not nothing throw.

    Thank you!

    The debugging 101 button: first thing make sure that the event handler running one) in fact, b) to what you think it is targeting. The two goals can be accomplished by sticking a trace() statement in the button click event handler that prints everything that you target your call gotoAndStop(). For example, if you have this:

    paramecium.panda.parallelogram.gotoAndStop (451);

    Add this entry:

    trace (Paramecium.Panda.Parallelogram);

    If nothing prints when you click the button, or it prints "undefined", you will have significantly reduced the problem.

Maybe you are looking for

  • Manage another iMac on the Internet?

    Is there a software that would allow me to manage another iMac on the Internet? It would be to help a senior relative when she has problems with her iMac. Thank you. Mac

  • Pavilion a775c power/reset button?

    I have an old hp Pavilion tower which has a motherboard BioStar inside. The other night, I was doing something when the screen went black and the light on the power switch will Flash yellow. Run fans, that the monitor only stop blinking when connecte

  • HP pavilion 15-n209eia: I need drivers for hp Pavilion n209eia 15 win7x64

    Hello Please I need help with my 15 hp for Pavilion-n209eia; It came with win 8.1 but crashed, I changed the hard drive and got a business in win 7 64 bit is installed. HP does not support win7 on this laptop but I have serched online and got the dri

  • system administrator password lock

    I have a HP Compaq Pesario F 700I forgot the administrator password.Deactivation of the system code: 07497

  • Ticks on both sides, CWGraph 3D axis values

    Hello I use Surface.vi 3D terrain surface 3D in CWGraph3D control. I put the Direction to the view (top) X - Y plane. I am able to check you for ticks on both sides of the lines, but I don't know how to duplicate the value labels and ticks (see attac