Get back ids based on ids having all one status

I have a table
CREATE TABLE [dbo].[myTable](
[p_id] [varchar](3) NOT NULL,
[s_id] [varchar](9) NOT NULL,
[d_name] [varchar](9) NOT NULL,
[status] [varchar](1) NOT NULL)
And it has the following data.
1 1 X1 N
1 1 X2 E
1 1 X3 E
1 2 Y1 E
1 2 Y2 E
1 2 Y3 E
1 3 Z1 N
1 3 Z2 N
I would like to get the p_id and s_id where all the records for a given p_id and s_id contain status = 'N'.  That is I'm look to get back p_id = 1 and s_id = 3 because all the records contain an 'N'.
lg

SELECT *
FROM
SELECT *,SUM(CASE WHEN status ='N' THEN 0 ELSE 1 END) OVER (PARTITION BY p_id,s_id) AS Cnt
FROM Table
)t
WHERE Cnt = 0
Use logic like above
if you want just distinct p_id and s_id value tweak it as below
SELECT DISTINCT p_id,s_id
FROM
SELECT *,SUM(CASE WHEN status ='N' THEN 0 ELSE 1 END) OVER (PARTITION BY p_id,s_id) AS Cnt
FROM Table
)t
WHERE Cnt = 0
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Is there any way that I can get back my iPhoto?  After having hard disk replaced (no backup) and the operating system has been updated to Lion (no disc) I am wondering if iPhoto can be reinstalled with my Leopard discs?

    Is there any way that I can get back my iPhoto?  After having hard disk replaced (no backup) and the operating system has been updated to Lion (no disc) I am wondering if iPhoto can be reinstalled with my Leopard discs?

    As Niel pointed out, yes.  The disk probably will look like the MBP disk (4) in this screenshot;
    OT

  • I am a new iPad Air user. How do I get back to the home page with all the icons.

    I Am a new user. How do I get back to the home page with all the icons.

    iPad Manual
    http://manuals.info.apple.com/en_US/ipad_user_guide.pdf

  • HT4910 I have an iPhone 3GS, for some strange reasons only 45 contact are getting backed up on icloud instead of all contacts

    I have an iPhone 3GS, for some strange reasons only 45 contact are getting backed up on icloud instead of all the contacts.
    Can you please help

    Welcome to the Apple Community.
    First check that all your settings are correct, that contact syncing is checked on all devices (system preferences > iCloud on a mac and settings > iCloud on a iPhone, iPad or iPod).
    Make sure the contacts you are adding are added to your 'iCloud' group and not an 'On My Mac', 'On My Phone' or other non iCloud group (you can do this by checking in groups), non iCloud contacts will not sync.
    If you are sure that everything is set up correctly and your contacts are in the iCloud group, you might try unchecking contact syncing in the iCloud settings, restarting your device and then re-enabling contact syncing.

  • HT2240 i already bought a quicktime pro version but lost the key some how. how can i get back that key, without buying a new one?

    i already bought a quicktime pro version but lost the key some how. how can i get back that key, without buying a new one?

    thank you Malcolm J. Rayfield for your replay. but this didn't help, because i bought the "pro" bevore that.

  • When I plug my device into my computer, it goes directly to the ITunes store. How do i get back to the main page with all my device info

    How do i get back to my device home page

    I had the same problem with mine when I connect the ipod when it's full charged and turn on. The problem never happen when the ipod is charging or i'ts full charged and it's turn off. So just turn off your ipod down and connect to your mac again.

  • I'm using internet explorer(yuk!!) and am having trouble with getting back my search engine "google" and all i get is "blank page", can u help?

    First of all, forgive me cuz I'm probably NOT the sharpest "chip in a laptop" but I use Internet Explorer as my ISP(I've heard that GOOGLE CHROME is soo much better??) and Google as my search engine. For some reason(I know, probably USER idiot!!) even though I have set in my "internet connections" tab, www.google.com chosen, the minute I click a new tab to look for something else, that dreaded "about blank" or maybe "blank page" comes up.....wtheck???? Can u help me pleeez......thank u ..

    It is possible that your security software (firewall, anti-virus) blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls
    *https://support.mozilla.org/kb/fix-problems-connecting-websites-after-updating
    See also:
    *http://kb.mozillazine.org/Error_loading_websites

  • Post Crash attempts to Get Back to OS X10.4.8 All Failing

    I am so close yet so far away.
    After 3 weeks of working on my Old Mac G4 (which was running 10.4.8 just fine before the crash), after running Disk Warrior (if you do have this Utility S/W on the self get it , it is the best $90 you will ever spend) to create a new directory to solve my B-Tree issues and after re-loading Tiger 10.4 from the Installation disk I am able to get the updates from Apple Support Downloads to update up to 10.4.11.  All others downloaded regardless of whether they are "Combo's" or "Incremental" will not install.  For example when I get past 10.4.2's S/W License Agreement and I see the drive mounted I want to load to it has a Red Exclamation Point on it and when I hit install I get the following message "Installing this software requires 125MB of space  (I have 8.7 GB and 1.25 GB SDRAM available). You can not install this Mac OS X Update on this volume. This volume does not meet the requirements for this update." What requirements are being refered to?  Is it Firmware Update that is neeed, is do which one? Any thoughts??
    The irony here is that the reason I know I was running up to 10.4.8 is that I have WD Backup Anywhere software loaded and it will not launch now as it requires a minimum of 10.4.8, so no access to my back-up files.  Yikes!
    Thanks for you help and insights, Michael

    I knew missing that day in 1st grade would come back to haunt me when the teacher covered number sequences!
    Talk about a forest for the trees situation, it is just that I have hit so many error loops ect. in this re-build I was thinking that 10.4.2 had a ZERO after it so 20 is bigger than 11. Right?
    OK, the Build # is 8S165 on my 10.4.11. What does that tell you?
    So now that I know I at least exceed the Minimum OS S/W requirement of 10.4.8, I am beginning to think I will have to re-install the WD Backup Anywhere.  I say this because regardless of whether I double click on its icon in the APPLICATION folder or in the shortcut in DOCK, the icon pops, the margins of a page explode outward and then nothing.  I am a little fearful to do so as I do not want to lose my backup archives.  I will get in touch with them directly for advise on what to do.
    Thanks so much for your response.  Michael

  • Locked out with file vault. Did fix by setting up new user account but cannot access old account with files                           but I can't get back into my old account with all my doc's and pics

    I was locked out by File Vault. I set up a new account by fooling the notebook it was a new start up. Now I cannot access my old account with all of my files. I can see it in Accounts but it will not let me access. Help

    I managed to get a few Time Machine Back Ups  before I passed away
    I'm not sure whether a ghost can do this, but if you were still alive, you could do as follows.
    First make sure you have read & write access to the folder you're trying to restore to. You should be able to see its contents in the Finder, and to move files in and out of it.
    This is an exception to the rule that you should never make any changes to backup data. I've tested this procedure in OS X 10.8 only. It should work with later versions, but I don't know whether it works in earlier versions. Use it only for files that were backed up from your home folder, or a folder on another volume created by you, and would normally be writable by you. Do not touch backups of system or application files.
    In the Finder (not in the time-travel view), navigate to the backup volume, then to the folder named "Backups.backupdb", and then to the snapshot you want to restore from. The snapshots are folders labeled with the date when they were created. Inside each of those folders is a file hierarchy like the one on the volume that was backed up. Descend through the hierarchy until you come to a folder named "Users," and inside that, a folder with your user name. The procedure will be different if you're trying to restore files on another volume.
    Select the folder and open the Info dialog (command-I). Click the padlock icon in the lower right corner of the window and authenticate. In the Sharing & Permissions section, give your account Read & Write access. You may have to close the dialog and repeat this step in order for the change to show up. Then click the gear icon and select
              Apply to Enclosed Items
    from the popup menu.
    Try the restore operation again, in the time-travel interface.

  • My iPhone isnt working with messages. The messages tend to get backed up and I receive them all later... The phone won't send iMessage during this time period... What do I do?

    The messages in the phone don't load until hours after they're received and seem to get overloaded very easily

    What would you do for transportation if you drove your car into a tree and had to wait while it was fixed? You'd need to rent, borrow or buy another car, no? The same applies to your phone. This is not Apple's problem; if the service center does not have replacements in stock for immediate swap-out, then it's up to you to provide a backup device or do without.
    If you're in a country where Apple provides direct service for iPhones, you may be able to call Apple support and arrange for advance replacement, where they send you the replacement phone and then you send back the old one. Apple offers such service in several countries, though you have to pay an extra fee for the service. If not, then you'll just have to wait for the service center to get in the replacement, and will have to arrange an alternative to use during that time.
    Regars.

  • In my iBooks store I have the crime and thriller category, but can't get back to the main page with all the categories.  Help!

    iBooks

    Is the store frozen i.e. can you navigate within that category ? You could try closing the iBooks app completely and then re-open it and see if it then works : from the home screen (i.e. not with iBooks 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the iBooks app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.

  • I accidentally clicked on "full page" and I hate it and now I don't know how to get back to where I can see all the tabs all the time. Help, Please!!!

    I think the question is pretty clear -- I don't know what additional details would be helpful. Questions?

    The F11 key toggles Full Screen Mode on or off.
    *See --> http://kb.mozillazine.org/Netbooks#Full_screen
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.com/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.com/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • I hit iPhoto send and I get: The email server didn't recognize your username/password combination. -- then can't get back to re-enter, which was correct one in first place.

    I have filled out an iPhoto "postcard" format with a message and photo, etc., and when I hit send, I get the message "The email server didn’t recognize your username/password combination." I hit OK but it does not clear to refill the log-in -- and I believe the info was correct to start. I'd like to save (and not have to re-crete) the card, but see no way of doing so, thus am fearful of closing it (for good).

    in the iPhoto preferences ==> accounts delete your e-mail account and reenter it
    OR
    IMHO the better solution is to set Apple mail as the email client in the iPhoto preferences
    LN

  • After latest security update firefox hangs frequently and is next to useless. HOW do I get back to what worked flawlessly till some one decided I needed to upgrade?

    Firefox hangs... IE won't respond to commands. Happens frequently ... have to use ctl alt del to shut it down. Just want my old browser back

    Symantec need to update their Firefox add-ons so that they are compatible with Firefox 4. They have indicated that for Norton 360 they plan to release an update to Norton 360 to support Firefox 4 in early May - http://us.norton.com/support/kb/web_view.jsp?wv_type=public_web&docurl=20100720113635EN&ln=en_US
    I do not know about the time scale for updates for other Norton products. Pending the update by Symantec, if you want to use the Norton add-ons you will need to downgrade to Firefox 3.6.
    To downgrade to Firefox 3.6 first uninstall Firefox 4, but do not select the option to "Remove my Firefox personal data". If you select that option it will delete your bookmarks, passwords and other user data.
    You can then install the latest version of Firefox 3.6 available from http://www.mozilla.com/en-US/firefox/all-older.html - it will automatically use your current bookmarks, passwords etc.
    To avoid possible problems with downgrading, I recommend going to your profile folder and deleting the following files if they exist - extensions.cache, extensions.rdf, extensions.ini, extensions.sqlite and localstore.rdf. Deleting these files will force Firefox to rebuild the list of installed extensions, checking their compatibility, and reset toolbar customizations.
    For details of how to find your profile folder see https://support.mozilla.com/kb/Profiles

  • HTML + JQuery (CSOM) to add multiple item to a Sharepoint list and get their IDs

    Hi everyone.
    I try to use HTML + JQuery in CEWP to build some sort of analog of InfoPath's repeating table in order to be able to insert multiple items in a Sharepoint list using CSOM.
    The current task is to get the IDs of inserted items (in order to use those IDs later to add attachments to the list items) as soon as they are added to the list. I've tried several ways but couldn't get the IDs of all inserted items. Usually
    I get "-1" as an ID for every item except the last one, which returns me the correct ID. 
    Bellow is the code.
    <script src="/testsite1/SiteAssets/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/testsite1/SiteAssets/jquery.SPServices.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    var click = 1;
    $("#btn_id_1").click(function() {
    click ++;
    $("#tr_id_1").clone().appendTo("#tbl_id_1").attr("id", "tr_id_" + click.toString()).find("input").val("");
    $("#btn_id_2").click(function() {
    Save();
    function Save() {
    var ctx = new SP.ClientContext.get_current();
    var taskList = ctx.get_web().get_lists().getByTitle('Tasks');
    var taskItemInfo = new SP.ListItemCreationInformation();
    var vendor;
    var certname;
    var certid;
    $("#tbl_id_1 tr").each(function() {
    vendor = ($(this).find(".vendor")).val();
    certname = ($(this).find(".certname")).val();
    certid = ($(this).find(".certid")).val();
    newTask = taskList.addItem(taskItemInfo);
    newTask.set_item('Title', vendor);
    newTask.set_item('Request_', certname);
    newTask.set_item('h', certid);
    newTask.update();
    ctx.load(newTask);
    ctx.executeQueryAsync(addTaskSuccess, addTaskFailure);
    //timeout();
    function timeout() {
    alert ("!!!");
    function addTaskSuccess(sender, args) {
    alert(newTask.get_id());
    //AddAttachment(newTask.get_id())
    function addTaskFailure(sender, args) {
    //alert(newTask.get_id());
    alert("no");
    window.location = window.location.pathname;
    </script>
    <div id="div_id_1" class="div_class_1">
    <table id="tbl_id_1">
    <tbody>
    <tr id="tr_id_1">
    <td>Vendor:<br><input type="text" class="vendor" /></td>
    <td>Cert. Name:<br><input type="text" class="certname" /></td>
    <td>Cert. ID:<br><input type="text" class="certid" /></td>
    <td>Attachment:<br><input type="file" class="attachment" /></td>
    </tr>
    </tbody>
    </table>
    <div><button id="btn_id_1" type="button" width="10" height="10">+</button></div>
    <div><button id="btn_id_2" type="button">Save</button></div>
    </div>

    Here's a working solution (thanks to
    this guy)
    <script src="/testsite1/SiteAssets/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/testsite1/SiteAssets/jquery.SPServices.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    var array = [];
    $(document).ready(function() {
    var click = 1;
    $("#btn_id_1").click(function() {
    click ++;
    $("#tr_id_1").clone().appendTo("#tbl_id_1").attr("id", "tr_id_" + click.toString()).find("input").val("");
    $("#btn_id_2").click(function() {
    //Save();
    //Call();
    var asyncPromises = Save();
    asyncPromises.done(function(result) {
    //alert(array.length);
    console.log(array.length);
    for (var i=0; i<array.length; i++) {
    //alert(array[i].get_id());
    console.log(array[i].get_id());
    asyncPromises.fail(function(result) {
    function Save() {
    var buildDeferredSaves = $.Deferred(function() {
    //var array = [];
    var ctx = new SP.ClientContext.get_current();
    var taskList = ctx.get_web().get_lists().getByTitle('Tasks');
    var taskItemInfo;
    var vendor;
    var certname;
    var certid;
    $("#tbl_id_1 tr").each(function() {
    vendor = ($(this).find(".vendor")).val();
    certname = ($(this).find(".certname")).val();
    certid = ($(this).find(".certid")).val();
    taskItemInfo = new SP.ListItemCreationInformation();
    newTask = taskList.addItem(taskItemInfo);
    newTask.set_item('Title', vendor);
    newTask.set_item('Request_', certname);
    newTask.set_item('h', certid);
    newTask.update();
    ctx.load(newTask);
    array.push(newTask);
    ctx.executeQueryAsync(
    function() {
    // Successful
    buildDeferredSaves.resolve();
    function(sender, args) {
    // Failure
    buildDeferredSaves.reject(args.get_message());
    return buildDeferredSaves.promise();
    </script>
    <div id="div_id_1" class="div_class_1">
    <table id="tbl_id_1">
    <tbody>
    <tr id="tr_id_1">
    <td>Vendor:<br><input type="text" class="vendor" /></td>
    <td>Cert. Name:<br><input type="text" class="certname" /></td>
    <td>Cert. ID:<br><input type="text" class="certid" /></td>
    <td>Attachment:<br><input type="file" class="attachment" /></td>
    </tr>
    </tbody>
    </table>
    <div><button id="btn_id_1" type="button" width="10" height="10">+</button></div>
    <div><button id="btn_id_2" type="button">Save</button></div>
    </div>

Maybe you are looking for

  • How to install Windows 7 on Macbook Pro without a CD

    I tried installing Windows 7 64 bit through boot camp, after I created a bootable disk drive through it on a usb and set it to install on 150gb of hard drive space it rebooted and said "No bootable device -- insert boot disk and press any key" I read

  • Multiple users of one icloud

    hi there now that icloud ist free, all family members have their own account. however, how do we access the calendars, bookmarks, photos, etc of each other? we have one family Iphoto library, one calender, etc.. with mobileme and only one account, th

  • I want to delete more than one song at a time from iTunes

    I want to delete whole albums from itunes. Is there a way to delete more than one song at a time?

  • 0FI_AR_4 Datasource, Delta

    Hi Experts, we are using 0FI_AR_4 datasource, this is delta enable, but the problem is we can run delta just once a day. Can any one please let me know how to change this so that i can run the delta more than once a day. Any document or a link would

  • Reporting scenario . Need extractor information

    Hi We have some reporting requirement from client to get the correct vendor evaluation report. In addition with standard vendor score , Client is also interested to see below score and values ? Could you please help me , how can i extract below value