How to find a data with the minimum value I get without using sub query

Currently, I manage to get a record by using subquery to find the minimum number, eg:
SELECT TAccTrn.ASysCde
FROM TAccTrn
WHERE TAccTrn.AAccTrnNum=(SELECT Min(TAccTrn.AAccTrnNum)
FROM TAccTrn, TDbtSchCltDtl
WHERE TDbtSchCltDtl.ASrcRefId=TAccTrn.ASrcRefId
AND TDbtSchCltDtl.ASrcRefSubId=TAccTrn.ASrcRefSubId
AND TDbtSchCltDtl.ASrcRefSeq=TAccTrn.ASrcRefSeq)
Is there any more idea without using the subquery?

Hi ,
What about using an in-line view and the row_number () analytic function...????
Here is an example....
SQL> select * from emp;
EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMM DEPTNO
7369 SMITH      CLERK      7902 18/12/1980     800,00               20
7499 ALLEN      SALESMAN   7698 20/02/1981    1600,00    300,00     30
7521 WARD       SALESMAN   7698 22/02/1981    1250,00    500,00     30
7566 JONES      MANAGER    7839 02/04/1981    2975,00               20
7654 MARTIN     SALESMAN   7698 28/09/1981    1250,00   1400,00     30
7698 BLAKE      MANAGER    7839 01/05/1981    2850,00               30
7782 CLARK      MANAGER    7839 09/06/1981    2450,00               10
7788 SCOTT      ANALYST    7566 18/04/1987    3000,00               20
7839 KING       PRESIDENT       17/11/1981    5000,00               10
7844 TURNER     SALESMAN   7698 08/09/1981    1500,00      0,00     30
7876 ADAMS      CLERK      7788 21/05/1987    1100,00               20
7900 JAMES      CLERK      7698 03/12/1981     950,00               30
7902 FORD       ANALYST    7566 03/12/1981    3000,00               20
7934 MILLER     CLERK      7782 23/01/1982    1300,00               10
14 rows selectedUsing a solution like the one you don't want ...(a subquery) i would write....
SQL> select ename from emp
  2    where hiredate=(select min(hiredate) from emp)
  3  /
ENAME
SMITHWhereas , using an in-line view....
SQL> select ename from
  2   (
  3    select ename,row_number() over(order by hiredate asc) row_num from emp
  4    )
  5  where row_num=1
  6  /
ENAME
SMITHIs it acceptable...????
Regards,
Simon

Similar Messages

  • HT1529 how to find my iphone with the serial number

    hi
    could you please tell how to find my iphone with the serial number ?

    Sorry, there is no way to do that.
    What To Do If Your iDevice or Computer Is Lost Or Stolen
    iPhone, iPod Touch, and iPad
    If you activated Find My Phone before it was lost or stolen, you can track it only if Wi-Fi is enabled on the device. What you cannot do is track your device using a serial number or other identifying number. You cannot expect Apple or anyone else to find your device for you. You cannot recover your loss unless you insure your device for such loss. It is not covered by your warranty.
    If your iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should have done in advance - before you lost it or it was stolen - and some things to do after the fact. Here are some suggestions:
    This link, Re: Help! I misplaced / lost my iPhone 5 today morning in delta Chelsea hotel downtown an I am not able to track it. Please help!, has some good advice regarding your options when your iDevice is lost or stolen.
      1. Reporting a lost or stolen Apple product
      2. Find my lost iPod Touch
      3. AT&T. Sprint, and Verizon can block stolen phones/tablets
      4. What-To-Do-When-Iphone-Is-Stolen
      5. What to do if your iOS device is lost or stolen
      6. 6 Ways to Track and Recover Your Lost/Stolen iPhone
      7. Find My iPhone
      8. Report Stolen iPad | Stolen Lost Found Online
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
      1. Find My iPhone
      2. Setup your iDevice on iCloud
      3. OS X Lion/Mountain Lion- About Find My Mac
      4. How To Set Up Free Find Your iPhone (Even on Unsupported Devices)
    Mac Computer
           Find My Mac can be used from Find My Phone at iCloud.com and via Find
           My Phone on your iDevice.
          The following is third-party anti-theft software:
               1.  STEM 2.1
               2.  MacPhoneHome 3.5
               3.  MacTrack 7.5.0
               4.  VUWER 1.7
               5.  Sneaky Bastar* 0.2.0
               6.  Undercover 5.1.1
               7.  LoJack for Laptops
               8. Hidden 2.0

  • How to find String associated with some long value.

    My requirement is to know the String associated with the long value, for ex 23423423 is having some value like 'skljflsjf'. Can any body findout soln for the same.
    Thanks
    ~ Chethangowda.

    My requirement is to know the String associatedwith
    the long value, for ex 23423423 is having somevalue
    like 'skljflsjf'. Can any body findout soln forthe
    same.
    Hum... I'm not 100% sure, but it seems the answeris:
    dgjldkgjfkljg
    Please, don't thank me before you confirm thething.
    Regards.Oooohhhh! That explains it! I guess I must've missed
    the part where he said he wants it translated to
    trollish. How stupid of me.You're absolutely not to blame... to be honest, if I had not read the OP 3-4 times carefully, I would not have found the solution.

  • Finding minimum value in each row using dynamic query

    need to find the minimum and maximum value from each row using dynamic query
    [from curr] will be given as input
    Tuky

    DECLARE @t TABLE(a INT,b INT,c INT);
    INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
    SELECT *
    ,      (   SELECT  MAX(val) 
               FROM    (VALUES (a)
                           ,   (b)
                           ,   (c)
                       ) AS value(val)
           ) AS MaxVal 
    ,      (   SELECT  MIN(val) 
               FROM    (VALUES (a)
                           ,   (b)
                           ,   (c)
                       ) AS value(val)
           ) AS MinVal 
    FROM @t;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How do i share pictures with other users on my Mac without using iCloud or photo stream

    How do I share pictures woth other users on my Mac without using iCloud or photo streaming?

    Simplest way is probably to put copies into the Users/Shared folder.

  • How to find compensation data for the year

    Dear All,
    Scenario:
    A company wants to know the comepnsation data for financial year 2009-2010.
    Problem: I couldnot find a single report which can provide the compensation of an employee for the year.
    We are trying to build a report however needs input if anyone has done that:
    Table which stores this data is PS_COMPENSATION.
    Problem is : it stores data in effective date.
    How to then convert it into a year -April 2010 to March 2011
    For example: cases
    a. existing employee: whose effective comp data will be less than April 2010
    - Plus, there are pay rate changes between April 2010 to march 2011. (Pay rate change can happen on any date of the month)
    - How can I add them to find the Compensation as per comp page from 1st April to 31st march 2011

    I'm afraid what you're looking for is not likely to be a trivial task. If you have all of the modules required for the "Report Total Compensation" product, then you should take a look at the associated PeopleBook. I think you will have to be on HRMS 9.0 at a minimum, and using Payroll for North America and Benefits Administration.
    To create a custom solution, you may have to consider a variety of other factors such job status--leave, terminated, terminated with pay, etc.--hourly vs. salaried, part time vs. full time, multi-job, variable compensation. It will depend entirely on the specific features that are being used at your site.
    If you provide a very detailed example of the output you are looking for with sample data, someone might be willing to offer a solution.
    Regards,
    Bob

  • How to access .dmp data with the Instant Client?

    I'm a total beginner, and am trying to access a .Dmp database. I have installed (on Linux i386):
    Instant Client Basic 11.2 + SDK + SQLPlus
    I'm aware that I have to further set the environment variables ORACLE_HOME and LD_LIBRARY_PATH, and think I know how it should be done.
    The files installed in the oracle directory are as follows:
    $ ls /usr/lib/oracle/11.2/client/lib
    glogin.sql libocci.so libsqlplusic.so ottclasses.zip
    libclntsh.so libocci.so.11.1 libsqlplus.so xstreams.jar
    libclntsh.so.11.1 libociei.so ojdbc5.jar
    libnnz11.so libocijdbc11.so ojdbc6.jar
    $ ls /usr/lib/oracle/11.2/client/bin
    adrci genezi sqlplus
    But this is where I hit the wall. Just a couple of questions:
    How do I make the Client to access the data? I've read a bit about name resolution such as tnsnames.ora and EZConnect, but have no idea what these are, even conceptually.
    How do I actually start/configure the Oracle client? Is there an executable somewhere?
    Can the .dmp file be even read by the client or do I have to use the SQLPlus to make queries (as I've read somewhere)?
    As you see I'm clueless. What are the next steps, or could you point me to a practical tutorial that would show what I need to do.
    Thanks a lot for any help..

    user9020180 wrote:
    Right,
    I browsed the manual, but I didn't understand whether the import utility part of the oracle database software?
    Are there any freely downloadable tools by which I can import the data (and then read with a client?).Everything in the Utilities manual is part of the database software set. If you have a database, you have all of those utilities. If you don't have a database, no third party equivalent to those utilities (if such existed) would be of any value.
    Depending on your database version, the .dmp file could have been created with either 'exp' (export) or 'expdp' (datapump). Unfortunately, by default both utilities produce a file with the .dmp extension, but they are different formats and not interchangeable. You will need to find out exactly how the .dmp file was created. Actually, you need to find out the entire command used to create it, not just which utility, because the options used at export time will affect what options are available and desirable at import time.

  • How to find an EXIT with the Include name ?

    Hi everybody
    If i have an Include name (like ZXMLUU16) , how can i find the FM Exit or the program where this include is used ?
    (NOTE: If i use SE38 and 'Where used' option , this
           only tell me 'Include ZXMLUU16 not found in
           selected search area')
    Thanks
    Frank

    I don't think there is a way to find that out, particularly if the include is not yet created. Typical with function module user exits is that, even though you see the line INCLUDE ZXMLUU16 statement in the function module code, the include itself is not created yet. Only when you double click, you will be creating it and then your 'where-used' should work.
    You just have to go by a hunch based on the name itself. Unn is a typical naming convension used for function module includes. So, I will take a wild guess that this include is in a function module that is in the function group XMLU. So if you look at this program SAPLXMLU and do a 'Find' 'In main program', you will see that the statement is in EXIT_SAPLMLSP_030.

  • Spotlight - how to find RTF files with the query language (kMDItemKind,etc)

    Hi folks. I'm trying to come up with a string that will find all RTF files.
    There are many strings for other docs -- like Microsoft Word is
    kMDItemContentType == "com.microsoft.word.doc"
    But I am trying to create one that will find all RTF files. There doesn't seem to be a kMDItem command for extension or anything, and if I type "com.nisus.writer" I'd just be guessing. And I only want to include RTF files.
    I'm probably missing something obvious, but I'm a complete non-programmer (obviously).
    Thanks.

    That's a partial solution, but it would be very helpful if one could somehow get the pathname onto the clipboard.  Being able to see the pathname is a lot less useful than being able to use it.

  • How to find last  date of the current year

    Hi
    Please tell me is there any function module to find out the last date of the current year.

    Hi,
    You can do that very simply like so.
    code
    report zrich_0001.
    data: first type sy-datum.
    data: last type sy-datum.
    first = sy-datum.
    first+4(4) = '0101'.
    last = sy-datum.
    last+4(4) = '1231'.
    write:/ first, last.
    [/code]
    OR use function modules
    1.use this function module HR_GB_TAX_YEAR_DATES
    Pass these values
    P08_TXYEAR = Year
    P08_PAYROLL_AREA = '01'
    2.use FM......... FIRST_AND_LAST_DAY_IN_YEAR_GET
    DATA: first LIKE sy-datum,
    last LIKE sy-datum.
    CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
    EXPORTING
    i_gjahr = '2007'
    i_periv = '24'
    IMPORTING
    e_first_day = first
    e_last_day = last.
    WRITE: / 'First Date', first, ' Last Date', last.
    Regards,
    Raj.

  • How to find login user with the largest account

    Hello. I'm looking to put together a bash script that can do two things: (1) determine the shortname of the user with the largest account in /Users and (2) look up their full/long name. I'm going to use this script to help identify who the user on a computer and while I know that's possible that a sometime-user may have a larger account than the normal-user on any given computer, the results of a script should be sufficient in most cases for my needs.
    I'm not sure the best way to around this. I know that I can use "du -m -d1 /Users" as root:
    root on torchwood
    [ ~ ]$ du -m -d1 /Users
    157 /Users/admin
    128 /Users/johndoe
    70890 /Users/dancollins
    21746 /Users/Shared
    92920 /Users
    I know that I can also use "dscacheutil -q user" to get a full list of all users on a system.
    How can I get both the short and long name of the user with the largest account in the /Users folder?

    We're running JAMF Recon for inventory and my supervisor wants to create a report that lists the primary user of the Mac... assuming that the largest user account may be the primary user. In this case, disk space is not the issue, the top admins simply would like to be able to associate names with individual machines. This isn't the most elegant way to do it and it's not fool-proof, but it'll be correct more often than not, which they're satisfied with.
    Can I ask one more question? Using your script, I've started testing with one building and on a number of Mac, the "admin" (shortname) account is turning out to be the largest account. Is there a way to exclude the admin account from consideration?
    Thanks...

  • Is there a way to sync the Notes app on my iPod Touch with the Notes on my desktop without using iCloud

    I've been reading some of the other threads about this issue, but most, if not all, suggest using iCloud. I'm wary of setting up an iCloud account because I've heard that "once your information is 'in the cloud' it can't be deleted", and I just don't know how true that is.
    Is there a way to sync the two apps by some other means that bypasses "the cloud"?

    I think that cloud privacy concerns are overdone - especially with Apple who don't have a vested interest in snooping through your data like Google does!
    Do you use email?  It's stored in the cloud on the providers servers - no matter who the provider is.
    Do you use SMS on a phone?  They're stored on a server somewhere!
    Do you use the internet?  The logs are stored at your ISP for some period of time - tracking everywhere you've been.
    Thats why I am comfortable to use iCloud for most of my documents.  If I want to transfer files very securely, I put them in an encrypted disk image on Dropbox.
    Cheers,
    Rodney

  • How do I transfer data from old laptop to new one without using time machine?

    I just bought a new Macbook and want to transfer everything over and wipe my old Macbook so the kids can have it.  I have an external hard drive, that has photos etc. on it already.  When I try to do a Time Machine back up, it tells me the drive is not formatted correctly and that to complete the back up, it will have to erase everything.  I can't move the photos back on to the old Macbook because there isn't enough free disc space.  So, I don't think I can do this with Time Machine.  How would you recommend I transfer the data over?  Thanks!

    Use Migration Assistant during the setup of the new machine. Connect both machines up to a wired network if possible and follow the instructions. It's worth running software update on the old MacBook first as there was an update to Migration assistant for OS X 10.5 and 10.6 published recently.

  • Removing the Duplicate Values from output without using Keyword DISTINCT

    Hi,
    I'm running the below query without DISTINCT Keyword and getting Duplicate results. can you please tell me what needs to be done if I want unique values without using Distinct.
    select hra.Location_code
    ,hra.Description
    ,hra.Address_line_1
    ,hra.Address_line_2
    ,hra.Address_line_3
    ,hra.town_or_city
    ,hra.Region_1
    ,hra.Postal_Code
    ,hra.country
    ,hra.attribute1
    ,hra.attribute5
    ,hra.attribute6
    ,hra.attribute8
    ,hra.attribute9
    ,hra.attribute2
    ,hra.attribute3
    ,hra.attribute4
    ,hra.attribute7
    ,hra.attribute10
    from hr_locations_all hra
    ,per_all_people_f papf
    ,per_person_types ppt
    , per_person_type_usages_f pptuf
    ,hr_all_organization_units haou
    ,hr_all_organization_units haou1
    where 1=1
    and hra.business_group_id = papf.business_group_id
    and hra.business_group_id = ppt.business_group_id
    and pptuf.person_id = papf.person_id
    and pptuf.person_type_id = ppt.person_type_id
    and ppt.system_person_type = 'EMP'
    and ((hra.inactive_date is null) or (trunc(hra.inactive_date)>= to_date('01/01/2012','mm/dd/yyyy')))
    and to_date('01/01/2012','mm/dd/yyyy') between trunc(pptuf.effective_start_date) and trunc(pptuf.effective_end_date)
    and((papf.effective_end_date is null) or (trunc(papf.effective_end_date)>= to_date('01/01/2012','mm/dd/yyyy')))
    and ((haou1.date_to is null) or (trunc(haou1.date_to)>= to_date('01/01/2012','mm/dd/yyyy')))
    and papf.business_group_id = haou.organization_id
    and hra.location_id = haou1.location_id;

    Hi,
    Try using this Code
    select hra.Location_code
    ,hra.Description
    ,hra.Address_line_1
    ,hra.Address_line_2
    ,hra.Address_line_3
    ,hra.town_or_city
    ,hra.Region_1
    ,hra.Postal_Code
    ,hra.country
    ,hra.attribute1
    ,hra.attribute5
    ,hra.attribute6
    ,hra.attribute8
    ,hra.attribute9
    ,hra.attribute2
    ,hra.attribute3
    ,hra.attribute4
    ,hra.attribute7
    ,hra.attribute10
    from hr_locations_all hra
    ,per_all_people_f papf,
    per_all_assignments_f paaf,
    per_person_types ppt
    , per_person_type_usages_f pptuf
    ,hr_all_organization_units haou
    --,hr_all_organization_units haou1
    where 1=1
    and
    hra.business_group_id = papf.business_group_id
    and hra.business_group_id = ppt.business_group_id
    and pptuf.person_id = papf.person_id
    and papf.person_id=paaf.person_id
    and pptuf.person_type_id = ppt.person_type_id
    and ppt.system_person_type = 'EMP'
    --and ((hra.inactive_date is null) or (trunc(hra.inactive_date)>= to_date('01/01/2012','mm/dd/yyyy')))
    and to_date('01/01/2012','mm/dd/yyyy') between trunc(pptuf.effective_start_date) and trunc(pptuf.effective_end_date)
    --and((papf.effective_end_date is null) or (trunc(papf.effective_end_date)>= to_date('01/01/2012','mm/dd/yyyy')))
    --and((paaf.effective_end_date is null) or (trunc(paaf.effective_end_date)>= to_date('01/01/2012','mm/dd/yyyy')))
    and to_date('01/01/2012','mm/dd/yyyy') between trunc(papf.effective_start_date) and trunc(papf.effective_end_date)
    and to_date('01/01/2012','mm/dd/yyyy') between trunc(paaf.effective_start_date) and trunc(paaf.effective_end_date)
    --and ((haou1.date_to is null) or (trunc(haou1.date_to)>= to_date('01/01/2012','mm/dd/yyyy')))
    --and papf.business_group_id = haou.organization_id
    and paaf.location_id=hra.location_id
    and paaf.organization_id=haou.organization_id
    --and papf.employee_number='1010008830'
    and hra.location_id = haou.location_id;

  • How to find System date in the query

    Hi,
    I have requirement where in the query I need to select the Document delivery date = today's date or system date.
    Can any once please let me know how to write the query?
    Murali

    Select * from ORDR where docduedate=convert(char(8), getdate(), 112)

Maybe you are looking for

  • Issue in Java Scipt

    Hello Experts, I have one issue in our client portal, which is really giving me hard time to resolve. So I have come to you experts for helping me to resolve this issue. So below are the details of the issue. Actually it goes like that, we are using

  • Says camera is in use by another program

    Eventhough nothign else is open. I recently upgraded to 10.4.8 in order to fix the sudden shut-down bug on macbooks. Now, iPhoto starts up when I start up. COuld these be related ot the iChat problem?

  • Installing Photoshop 8 on an iMac

    I own Photoshop Elements 8 which is installed on my PC,  I recently purchased an iMac and would like to install the same version.  How do I do this?  The disc I have does not seem to allow me to install it on the Mac.

  • Jbuilder produced class files?

    I have a problem converting class files produced by JBuilder IDE (v 6.0). The converter reports the following error: "Missing static field initializer in field XYZ", where XYZ is declared in the source as: final static byte XYZ = (byte)0; If I declar

  • Blutooth

    How do i download blutooth drivers for compaq cq61