How can i select some row from multiple row in the same group of data

I want to select some row from multiple row in the same group of data.
ColumnA        
Column B
1                  OK
1                   NG
2                   NG
2                          NG
3                          OK
3                          OK
I want the row of group of
ColumnA if  ColumnB contain even 'NG'
row , select only one row which  Column B = 'NG'
the result i want = 
ColumnA         Column B
1                         NG
2                   NG
3                          OK
Thank you

That's some awful explanation, but I think this is what you were driving at:
DECLARE @forumTable TABLE (a INT, b CHAR(2))
INSERT INTO @forumTable (a, b)
VALUES
(1, 'OK'),(1, 'NG'),
(2, 'NG'),(2, 'NG'),
(3, 'OK'),(3, 'OK')
SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
FROM @forumTable f
LEFT OUTER JOIN @forumTable f2
ON f.a = f2.a
AND f.b <> f2.b
GROUP BY f.a

Similar Messages

  • How can we read some bytes from every line of the file

    How can we read some bytes from the every line of the file moving on to the next line
    without using the read line

    Actualiy readLine() takes more execution time
    for reading a part of line if we can do so without
    readLine() we can save some time...Well, if you knew, beforehand, the length of each line, you could use RandomAccessFile and its seek method, but, since you don't, you would have to read the rest of the line character-by-character, checking to see if it is a newline, in order to place the "cursor" at the beginning of the next line in order to read the next few characters you want.
    So, as you can see, you will need to read the entire line anyway (and if you do it yourself you also have to do the checking yourself considering all three possible end-of-line sequences), so you just as well use readLine().
    Some people may suggest Scanner and it's nextLine() method, but that also needs to read the rest of line (as evidenced by the fact that it returns it), so that is no different than the readLine() (or read it yourself) solution.

  • How can I install one app on multiple iPads at the same time?

    We have a volume purchasing account, but when purchasing an app we get multiple serial numbers that all seem to need to be entered individually. The iPhone config Utility will not sync multiple iPads at the same time. Am I missing something? This cannot be the method for mass deployment, it seem too complicated.

    You can do a  backup of you iPad then restore the backup to many devices.
    How to use multiple iPods, iPads, or iPhones with one computer
    http://support.apple.com/kb/HT1495
    Mobile Device Management Solutions for iOS
    http://www.apple.com/iphone/business/integration/mdm/
    http://www.apple.com/ipad/business/resources/
    "iOS mobile device management (MDM)
    With an unmatched breadth of features, a Self Service console forover-the-air (OTA) distribution of in-house and app store apps, and integration with Apple's Volume Purchase Plan (VPP), the Casper Suiteallows administrators to easily achieve the four major tenets of iOSmobile device management: Inventory, Configuration, Security Management, and App Distribution."
    http://jamfsoftware.com/products/casper-suite/

  • How can I move some track from music folder to the podcast or audiobook?

    I have a lot of audiobook in my hard drive.When I add these files to library,they place in the music section.How can I move Them to the audiobook section?
    I've tried to chenge their genre to the Podcasts or Books,but there is nothing happened.

    So, if she purchased a song from iTunes in her library, I will also have to purchase the same song to add to my library?

  • My daughter and I each have iTunes libraries on the same computer, how can I move some songs from one library to the other?

    My daughter and I each have iTunes libraries on the same computer, how can songs from one library be moved to the other?

    So, if she purchased a song from iTunes in her library, I will also have to purchase the same song to add to my library?

  • How can I create a hashmap() with multiple values for the same key?

    I am trying to write an application that will us something like a Map() with multiple values but some have the same key. Is this possible?

    i had the same question. just create a List, add all the values u want to it, and then put the List into the map like u would a normal single value. e.g.
    List list = new ArrayList();
    list.add(value1);
    list.add(value2);
    map.put(key, list);
    i bet u r doing the same course as i am =)

  • Spreadsheet: how can I store test results from different tests in the same central spreadsheet?

    I am looking to gather test data using LabVIEW. I then want to store all the data in the same spreadsheet, a kind of central data base. I know how to store single test data in a spreadsheet but I can I get the software to write new data in the same file without over writing the old data?

    My first recommendation is that if you need a database--use a database not a spreadsheet. A DBMS isn't that hard to use and could pay big dividends in the future.In any case, to answer your question directly, it sounds like you are writing tab-delimited data to a text file that you will then open with a spreadsheet program. On the file write vi is a boolean input that specifies whether the new data should be appended or overwrite the existing data (the default is to overwrite). Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Can't download a song from different version of the same group/album

    Well, I'll try to be as specific as I can. Here it goes: There are two versions of Muse's album "The 2nd Law" - Normal and Deluxe. I've bought Madness song from Normal version, then I previewed the whole album, liked it and decided to "Complete the album". But I did that with Deluxe version - not Normal.
    As a  result I have incomplete Deluxe album (without Madness song) and just lone song in Normal album... There's no way to download Deluxe version of Madness now. It says "Purchased" but doesn't allow me to download it. Hiding/deleting Normal song doesn't help either.
    Is there any way to complete Deluxe album now? Or replace Normal version of Madness song with Deluxe one?
    And before you asked - there's slightly (but audible) better quality of the recording in the Deluxe version.

    You can try contacting support thru this link http://www.apple.com/support/itunes/contact/
    so they can assist you with this.

  • How can I transfer some photos from PE11 to be saved on my new IPad?

    How can I transfer some photos from PE11 to be saved on my new IPad? I know I can use Adobe Revel but that relies on an Internet connection. The person I wish to show the photos do not have internet connection.

    You can use iTunes on your local computer to transfer photos:
    http://www.howstuffworks.com/tablets/transfer-pictures-to-ipad.htm

  • How can I delete some music from my iCloud but not from my iTunes in my computer? please??

    how can I delete some music from my iCloud but not from my iTunes in my computer? please??

    iCloud doesn't store your music.

  • How can i share some apps from my macbook pro to iMac on different IP?

    how can i share some apps from my macbook pro to iMac on different IP?

    sign into same id on both computers in the app store
    see this
    http://support.apple.com/kb/HT2519
    Peace, Clyde

  • How can i delete some books from ibook?

    How can i delete some books from ibook? It says: this book can't be opened. The book is corrupt. I can't open and I can't delete it

    I was unable to delete a book sample from my iPhone 5s running iOS 7.  This seems to be what worked for me.  I went to the Library and clicked "edit" in upper right side of the screen.  I then tapped one time on the book I wanted to remove and a blue check appeared at the bottom right corner of that book (presumably you could tap several at a time)  Anyway, when the blue check is on the book, you will see in the upper left of the screen the word "Delete" (mine was in red) I clicked that and then a confirming dialog came up from the bottom of the screen with the choices of "delete" or "cancel".  I chose "delete" and the book was gone.  Hope this helps.

  • How can I transfer some songs from my ipod to my itunes library although they are not purchased from itunes store?

    How can I transfer some songs from my ipod to my itunes library although they are not purchased from itunes store?

    By using one of third-party programs discussed in this previous discussion:
    Best iPod to PC

  • How can I save some pics from my Mac onto my Ipod touch?

    How can I save some pics from my Mac to my Ipod Touch ?

    Syncing photos with iTunes is explained here: http://support.apple.com/kb/HT4236
    You'll have to choose the photos you want to sync in the photo pane in iTunes with your phone connected, then apply sync.

  • How can I remove some themes from Keynote??

    How can I remove some themes from Keynote??

    What a co-incidence... I just deleted those same goodies. They were in /Library/Application Support/Keynote-folder on my machine. I just deleted the whole folder, cause there seemed to be nothing more but those downloaded files. And Keynote worked great afterwards. There seemed to be another folder for iWork09, which is not to be removed.

Maybe you are looking for

  • How can i call a CGI script from java?

    The subject pretty much says it all. I want to call a perl cgi script so i can read from/write to files on a server. I don't know how to sign applets and this would be the easiest way for me, if someone could please tell me.

  • Problem with posting goods receipt

    Hi Gurus, My PO is created for a material  with quantity 45000 nos. Overdelivery tolerance is 20%. Already GR is posted for 48000 nos and MIRO is posted for the same. Now, I want to post GR for the remianing qty ie. (45000*1.2) - 48000 = 6000 nos. Wh

  • How do I install snow leopard on to a new blank hard drive?

    I just bought a new 1TB Seagate Sata Solid State and properly installed it into my 2006 model Macbook because I was running out of space. But I can't figure out how to get snow leopard back on. I've been researching all day and I've tried partitionin

  • Black border around my mouse pointer

    Since a few days, I have a thick black border around my mouse pointer, always following the movement of the pointer. How can I bring this away? Thanks for help Ueli

  • Production Order variance report

    Hi, Is there any standard report where we can find the variance analysis for a Production Order?