How do I get this sql query?

Hi all

I'm using oracle 11g.

I have a table as below:

[code] create table id_test)

Identification number, name varchar2 (20)

) ;

[/ code]

And records like below:

[code]

ID NAME

1 sr

1 ds

2 sr

DS 2

3 sr

[/ code]

where I want to select only the id that have only the name as "sr."

But as I have 100 names cannot put a not in condition to check other names.

The expected result would be like:

[code]

ID NAME

3 sr

[/ code]

Concerning

Dale

Do you want to max (id) name = "SR"... Try the below

SELECT id,

name

GO (select id,

name,

ROW_NUMBER() over (ORDER BY id desc) rn

of id_test

WHERE name = 'sr')

WHERE rn = 1

OR

SELECT MAX id (id),

name

Of id_test

WHERE name = 'sr '.

GROUP BY name.

OR if you want to get the id which is only in SR, then try it out below

SELECT id,

name

Id_test A1

WHERE name = 'sr '.

AND NOT EXISTS (SELECT 1 from id_test a2

WHERE a1.id = a2.id

AND name! = « sr ») ;

Post edited by: 000000

Tags: Database

Similar Questions

  • How do I get recommendations sql query manually, its possible or not?

    I'm new dba oracle and my company gives me sql optimize, if research on google and knowledge, addm can give recommendations of sql query

    but I sql query and in addm can not give recommendations,

    I then how sql query performance increase... ?

    and the sql script to get the recommendations?

    Thanks in advance

    1. upgrade to oracle 11

    2. (take the topgun)

    Select / * + RESULT_CACHE * / a.empid, empname from

    (select empid, empname from india_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from us_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from uk_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from uae_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from brazl_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from chine_emp

    where deptno <> 10 and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    Union of all the

    Select empid, empname from jpn_emp

    where deptno in (54,256,362,9879,24,46) and empid NOT IN (105,202,11,45,695,646,726,8465,965,56,646,689,446)

    ) a

    order by 2;

    3. run the query 3 times.

    The query will be lightning fast from the 3rd time

    4. read the full performance tuning guide

    http://docs.Oracle.com/CD/E11882_01/server.112/e41573/TOC.htm

  • How can I apply this two query?

    I have two employees from table to table and CSEReduxResponses

    As part of table, I

    CREATE TABLE [dbo].[employee](
      [emp_id] [int] IDENTITY(1,1) NOT NULL,
      [emp_namefirst] [varchar](255) NOT NULL,
      [emp_namemiddle] [varchar](50) NULL,
      [emp_namelast] [varchar](255) NOT NULL
    ) 
    

    I react

    CREATE TABLE [dbo].[CSEReduxResponses](
      [response_id] [int] IDENTITY(1,1) NOT NULL,
      [employee] [int] NOT NULL,
      [employeedept] [int] NOT NULL,
      [star] [tinyint] NOT NULL,
      [status] [int] NOT NULL,
      [approvedby] [int] NULL,
      [approveddate] [datetime] NULL,
      [execoffice_status] [int] NULL,
    
    
    )
    

    Im trying to get the employee with the execpffice_status of MAX (it's a 1 or 0).

    I have this request I made for her

    select top(1) with ties employee, SUM(execoffice_status) as 'total'
      from   CSEReduxResponses
      group by employee
      order by 'total' desc
    

    my request for the employee table is

       select emp_namefirst as first , emp_namelast as [last]
      from phonelist.dbo.employee where emp_namefirst is not null
    

    How can I get this request 2 together so I can output the name of the employee (first and last)

    with the max exeoffice_status?

    IM using

    Microsoft SQL Server Management Studio10.0.2531.0

    WRONG FORUM!

    This forum is for Oracle - you must post in a forum of sql server.

    Please mark the thread ANSWERED and repost in the appropriate forum.

  • How can I get this popup of Yahoo to stop?

    When browsing, a popup of Yahoo appears often invites you to add an extension of yahoo. I don't want the extension, but this option is not given. All I can do is close the popup only to reappear a few clicks later. How can I get this popup to stop? I have the box "block pop-up windows" checked in the preferences.

  • How do I get this to stop: 'Yahoo is the favorite for Firefox search engine. Switch now. »

    The above message whenever I go to my Yahoo mail. I really don't like Yahoo search. How can I get this message to stop popping up? Since then it has begun to appear Yahoo mail is glitchy and slow (only on 2 computers with Firefox). I want to keep Firefox, but if it is not repairable.

    I wonder if you have Yahoo or some other add-on toolbar that makes the promotion of Yahoo search. I ask because even when I open Yahoo in a private window to circumvent any existing cookies, I don't see this message. (But I am certainly block some ad servers used by Yahoo).

    Could test you mode without failure of Firefox? It is a standard diagnostic tool to disable some advanced features of Firefox and extensions. More info: questions to troubleshoot Firefox in Safe Mode.

    Does not work if Firefox: Hold down the SHIFT key when you start Firefox.

    If Firefox is running: You can restart Firefox in Mode safe mode using either:

    • button "3-bar" menu > "?" button > restart with disabled modules
    • Help menu > restart with disabled modules

    and OK reboot.

    Two scenarios: A small dialog box should appear. Click on 'Start mode safe' (not update).

    Any difference?

  • When I launch Firefox, just my homepage allows the opening, all of a sudden, that, with a new tab opens - how do I get this to stop

    When I start Firefox, just my use of the homepage (my g-mail) to open. All of a sudden, my homepage and some free computer game page opens. How can I get this other page to open no more?

    Thank you!

    Do you have the same two tabs when you launch a new window (Ctrl + n) or only at startup?

    You can check your extensions in case something snuck in. You can view and clear the page modules. Either:

    • Command + shift + a
    • "3-bar" menu button (or tools) > Add-ons

    In the left column, click Extensions. Then, when in doubt, turn off.

    Typically, a link will appear above at least an extension disabled to restart Firefox. You can complete your work on the tab and click one of the links in the last step.

    Who closes down the extra page?

  • Maps app shows wrong time, how do I get this changed for my business?

    My customers using cards iphone App get bad times for my business. Cards apps is from 18:00, we close at 5:30 and the Apple. My website, facebook, yelp, google maps and all the ads say 05:30. How do I get this changed on Maps Apple application?

    Send feedback to Apple. They will not respond, but at least know that there is a problem.

    Your comments

  • I missed the prompt to update my notes. My software is up to date, but there is no option to update notes. How can I get this opportunity again? I want to sketch options and make interactive lists.

    I missed the prompt to update my notes. My software is up to date, but there is no option to update notes. How can I get this opportunity again? I want to sketch options and make interactive lists.

    Open the Notes app and look near the upper left corner to see if the upgrade option is there.

  • I bought a mini iPad 4 than does ' t have FaceTime. How do I get this resolved.

    iPad Mini 4 does ' t have Facetime, how do I get this resolved.

    • iPad Mini - 4
    • 16 GB
    • WiFi only
    • iOS - 9.2

    I bought this iPad in SAUDI ARABIA,

    FaceTime is blocked by the Saudi Government. You won't be able to get it on your iPad even if you move to another country.

  • How can I get this picture?

    Hi all:

    How can I get this curve (for example: XY waveform or other?)? If the curve data are kown.


  • Internet Explorer and other applications open as microsoft works. How can I get this problem?

    Original title: all the applications on my computer appear as microsoft works. How can I get this problem? Even internet explore a works file is not displayed and does not open.

    All my desktop icons are listed under the ribs owrks and work does not support these applications. How to get back my computer to the way it was?

    Hello

    1. which is the version of Windows installed on your computer? For example, Windows 7, Vista

    2. have you done any software or hardware changes on your computer before this problem?

    I suggest you to see the steps in the following link.

    When you run an .exe on a Windows XP, Windows Vista or Windows 7 computer file, the file can start another program

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

    Registry warning

    To do: Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    322756 (http://support.microsoft.com/kb/322756/ )

    http://Windows.Microsoft.com/en-us/Windows7/back-up-the-registry

    Hope the information is useful.

  • We moved and we lost the record to go with the microsoft download number modules to our new computer and it will not let us download micro Word &#62; how do we get this registration?

    We moved and we lost the record to go with the microsoft download number modules to our new computer and it will not let us download micro Word > how do we get this registration?

    Unfortunately, if you have lost the product keys for Microsoft software, you will need to buy new software.  Visit the Microsoft store on genuine Microsoft software.

  • My CD of Windows XP Proffesional will be not performed or read. How do I get this replaced?

    My CD of Windows XP Proffesional will be not performed or read. How do I get this replaced?

    How to replace lost, broken, or Missing Microsoft Software or Hardware - http://support.microsoft.com/default.aspx?scid=KB;en-us;326246

    If it's an OEM license, you should contact that anyone who sold you the PC.
    MS - MVP - Elephant Boy computers - don't panic!

  • I'm trying to uninstall Verizon's VZ Access Manager. I get "invalid UNINSTALL Uninstall Wise. LOG file. How can I get this off for Verizon can help me to get the new drivers installed?

    I'm trying to uninstall Verizon's VZ Access Manager.  I get "invalid UNINSTALL Uninstall Wise. LOG file.  How can I get this off for Verizon can help me to get the new drivers installed?

    Hello retabox, welcome.

    It would seem that the installer is corrupted. I recommend trying to use the Windows Installer Cleanup utility to force - to remove the application. Try this:
    2. click on the download link in the middle of the page
    3. save the file to your desktop or just click Run the installation of the application
    4. once the application is installed, open the utility. The utility must be located in the menu START under (START > programs > Windows Installer...)
    5. in the utility, find the application you want to uninstall, and then click the button 'delete' below
    6. once removed, restart the computer and see if you can reinstall the application
    Let us know if it works,
    Thank you!

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

  • I try to upgrade my old vista laptop to win7, but don't remember the product key for my computer compaq laptop. How can I get this key?

    * Original title: get the product key

    I try to upgrade my old vista laptop to win7, but don't remember the product key for my computer compaq laptop. How can I get this key?

    Hello

    Your question is not very clear to understand.

    If Vista is preinstalled on your laptop, this product key is NOT for Windows 7.

    There is a free upgrade from Vista to Windows 7 years, but that offer expired for a long time.

    How does the Windows 7 upgrade Option?

    The Windows 7 upgrade Option is available through participating PC manufacturers on some PC and Microsoft on any purchase of packaged product Windows Vista. The Windows 7 upgrade Option applies to Windows Vista Home Premium, Business and Ultimate editions. Your Windows 7 update will be the comparable version: so you will get either Windows 7 Home Premium, Windows 7 Professional (upgrade to Windows Vista Business) or Windows 7 Ultimate, respectively. The Option of upgrade Windows 7 program runs from June 26, 2009 through January 31, 2010. Some manufacturers may choose to shorten the time of upgrade Option.

    Microsoft sells more than Windows 7, but it does NOT come for free.

    Try Amazon.com, etc.

    ___________________________________________________________

    And if you ask to transfer the license of Windows 7 from a mobile to another laptop:

    You tell us what type of license you have.

    If the laptop came with the preinstalled Windows operating system (Dell, HP, Acer, etc.), this product key supplied with the laptop is preinstalled OEM license and is not transferable.

    OEM license/product key (systems of operating pre-installed on Dell, HP, etc.) is related to the first machine it is installed on and dies when dies of this machine.

    The above applies also to OEM system builders licenses.

    License of operating system in detail, that you buy and install yourself, are allowed to be transferred to another machine.

    And retail licenses also can be installed on a machine at one time.

    ___________________________________________________

    And please read this, you can:

    http://www.Microsoft.com/OEM/en-GB/licensing/sblicensing/pages/licensing_faq.aspx#fBid=cbW6pY-wjS6

    @@@@@@@@@@@@@@@@@@@@@@@@@

    If you had a 7 upgrade that you have bought yourself on the HP laptop, use programs Key Finder for the PK:

    http://www.Belarc.com/free_download.html

    https://www.magicaljellybean.com/KeyFinder/

    See you soon.

Maybe you are looking for