What is the Oracle equivalent of the Microsoft Access FIRST function?

Using: Oracle 10gR2 RAC on SUSE Linux 9 (10.2.0.3)
In the process of converting a Microsoft Access database to Oracle, an Access query is using the FIRST function.
What is the Oracle equivalent of the Microsoft Access FIRST function?
In the attempt to convert, the Oracle FIRST_VALUE function was used. However, the same results was not achieved.
Thanks,
(BLL)
Query:
h2. ACCESS:
SELECT
     TRE.GCUSNO,
     UCASE([DCUSNO]) AS DCUSNO_STD,
     *FIRST(UCASE([DNAME])) AS DNAME_STD*,
     *FIRST(UCASE([DADDR])) AS DADDR_STD*,
     *FIRST(UCASE([DCITY])) AS DCITY_STD*,
     TRE.DSTATE,
     FIRST(TRE.DZIP) AS DZIP,
     TRE.DREGN,
     TRE.DDIST,
     TRE.DSLSMN,
     TRE.DCHAIN,
     TRE.MARKET,
     TRE.MKTPGM,
     TRE.EUMKT
FROM
     TRE
GROUP BY
     TRE.GCUSNO,
     UCASE([DCUSNO]),
     TRE.DSTATE,
     TRE.DREGN,
     TRE.DDIST,
     TRE.DSLSMN,
     TRE.DCHAIN,
     TRE.MARKET,
     TRE.MKTPGM,
     TRE.EUMKT;
h2. ORACLE:
SELECT DISTINCT
TRE.GCUSNO,
UPPER(TRIM(TRE.DCUSNO)) AS DCUSNO_STD,
UPPER(TRIM(TRE.DNAME)) AS DNAME_STD,
UPPER(TRIM(TRE.DADDR)) AS DADDR_STD,
     FIRST_VALUE(UPPER(TRIM(TRE.DNAME)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DNAME_STD,
     FIRST_VALUE(UPPER(TRIM(TRE.DADDR)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DADDR_STD,
     FIRST_VALUE(UPPER(TRIM(TRE.DCITY)) IGNORE NULLS) OVER (ORDER BY TRE.GCUSNO) AS DCITY_STD,
TRE.DSTATE,
TRE.DZIP,
FIRST_VALUE(UPPER(TRIM(TRE.DZIP)) IGNORE NULLS) OVER (ORDER BY TRE.DZIP ASC) AS DZIP,
TRE.DREGN,
TRE.DDIST,
TRE.DSLSMN,
TRE.DCHAIN,
TRE.MARKET,
TRE.MKTPGM,
TRE.EUMKT
FROM CRM.TREUP100R TRE
GROUP BY
TRE.GCUSNO,
UPPER(TRIM(TRE.DCUSNO)),
TRE.DNAME,
TRE.DADDR,
TRE.DCITY,
TRE.DSTATE,
TRE.DZIP,
TRE.DREGN,
TRE.DDIST,
TRE.DSLSMN,
TRE.DCHAIN,
TRE.MARKET,
TRE.MKTPGM,
TRE.EUMKT;

A slight correction to odie's post. I think you want min not max to replicate the Access first function, but see below to be sure. So:
min(upper(trim(tre.dname))) keep (dense_rank first order by tre.gcusno) as dname_std
user10860953 wrote:How does one ignore null values?The min and max functions will ignore nulls automatically, so if there is a null value in tre.dname, it will not be be returned, unless all of the values are null. For example:
SQL> WITH t AS (
  2     SELECT 65 id, 'ABCD' col FROM dual UNION ALL
  3     SELECT 37, 'DEFG' FROM dual UNION ALL
  4     SELECT 65, 'DEFG' FROM dual UNION ALL
  5     SELECT 65, null FROM dual UNION ALL
  6     SELECT 70, null FROM dual UNION ALL
  7     SELECT 70, null FROM dual UNION ALL
  8     SELECT 37, 'ABC' from dual)
  9  SELECT id,
10         MIN(col) keep (DENSE_RANK FIRST ORDER BY id) min_dname_std,
11         MAX(col) keep (DENSE_RANK FIRST ORDER BY id) max_dname_std
12  FROM t
13  GROUP BY id;
        ID MIN_ MAX_
        37 ABC  DEFG
        65 ABCD DEFG
        70John

Similar Messages

  • What is the Microsoft toll that will check in sharepoint server for updates

    Hi
    what  is the Microsoft toll that will check in sharepoint server
    which package  will need update or not
    and it will tell updates and patches need or not
    adil

    This is entirely handled by Windows/Microsoft Update built into Windows itself.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Oracle equivalent of SQLDMO (Microsoft)

    Is there a library/dll/object that is COM complient that will allow one to do DML, etc.?
    Or does Oracle have a linkable object for Microsoft C/C++, like Embedded SQL. I guess a better question is does the embedded SQL complie in Microsoft C (v. 6.0)?

    A slight correction to odie's post. I think you want min not max to replicate the Access first function, but see below to be sure. So:
    min(upper(trim(tre.dname))) keep (dense_rank first order by tre.gcusno) as dname_std
    user10860953 wrote:How does one ignore null values?The min and max functions will ignore nulls automatically, so if there is a null value in tre.dname, it will not be be returned, unless all of the values are null. For example:
    SQL> WITH t AS (
      2     SELECT 65 id, 'ABCD' col FROM dual UNION ALL
      3     SELECT 37, 'DEFG' FROM dual UNION ALL
      4     SELECT 65, 'DEFG' FROM dual UNION ALL
      5     SELECT 65, null FROM dual UNION ALL
      6     SELECT 70, null FROM dual UNION ALL
      7     SELECT 70, null FROM dual UNION ALL
      8     SELECT 37, 'ABC' from dual)
      9  SELECT id,
    10         MIN(col) keep (DENSE_RANK FIRST ORDER BY id) min_dname_std,
    11         MAX(col) keep (DENSE_RANK FIRST ORDER BY id) max_dname_std
    12  FROM t
    13  GROUP BY id;
            ID MIN_ MAX_
            37 ABC  DEFG
            65 ABCD DEFG
            70John

  • The Microsoft Access database engine cannot open or write to the file in Report Builder 3.0

    I am trying to build a report in Report Builder 3.0.  I created the Data Source to point to my Excel file and the Data Set.  I drag a couple of fields on to the canvas and then choose Run.  I get the error:  "The Microsoft Access
    database engine cannot open or write to the file.  It is already opened exclusively by another user".  I am using the Excel driver.  Why am I getting this message?  How can I fix this?

    No, now I am getting the error message again.  It is quite long:
    ERROR [HY000] [Microsoft][ODBC Excel Driver] The Microsoft Access database engine cannot open or write to the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view and write its data.
    ERROR [01S00] [Microsoft][ODBC Excel Driver]Invalid connection string attribute Trusted_Connection
    Please help

  • How do I get mail on my iPhone and computer to sync automatically, so e.g. messages read on one appear read on both?  I am working in VN and the microsoft access server is in the USA.

    How do I get mail on my iPhone and computer to sync automatically, so e.g. messages read on one appear read on both?  I am working in VN and the microsoft access server is in the USA.

    If you created as an Exchange account on the iPhone (not IMAP or POP) and you have Push on it should all work smoothly; Reading a message on either client should mark the other read (it does on mine). Try deleting the account from the phone, rebooting the phone (to clear out old settings), then go to Settings/Mail,Contacts,Calendar, add an account and tap Microsoft Exchange and add the account back.
    There is a fundamental difference between BB and iPhone that you should be aware of; on the BB you do not sync directly with Exchange; you sync with the RIM server which then syncs with your Exchange server. The iPhone syncs directly with Exchange using Microsoft's ActiveSync protocol. So in some ways they will behave differently. But ActiveSync should manage marking messages as read correctly.

  • What are  the input parameters for Function Module

    Dear Experts,
    I want to generate a Sales Tax returns report,those fields are not available in my existing Datasources.
    For that i want to write a Generic Datasource with Function Module.
    audat
    bukrs
    vkorg
    vtweg
    spart
    aurat
    auart
    netwr
    mwsbp
    kschl zedp(consition type)
    kschl zvat(condition type)
    ksch   zcst(condition type)
    matkl     material group
    Here what are the Input parameters for Function Module.
    Thanks in Advance.
    Srinivasan.

    Srinivasan-
    For creating a Generic extractor based on a FM, you first of all need to know what is going to be your structure.. i.e. what all fields you need to pull from what all tables. A functional consultant may help you identify the exact DB tables.
    Once you know them, hand over the requirement and the pdf mentioned by Krishna to the ABAP guy, he would be able to take this up further.
    Also decide 1st whether you would be using a full load or delta. There is a slight difference in the way they are built.
    Let me know how it goes.
    -Bhushan.

  • The Microsoft Access database engine cannot open or write to the file \\fileserver\db\access.mdb

    Hi,
    I have Windows Server 2012 with SQL 2012 Standard SP1. I am using linked server, and Access Database Engine 2010 Redistributable to access my database file made in Microsoft Access (.mdb) from network file server.
    EXEC master.dbo.sp_addlinkedserver @server = N'MyLinkedServer', @srvproduct=N'MyLinkedServer', @provider=N'Microsoft.ACE.OLEDB.12.0', @datasrc=N'\\myfileserver.mydomain.com\files\mydatabase.mdb'
    My SQL service is running with domain service account MYDOMAIN\SQL1$ , i have added Full control for file share and NTFS permission on my file server folder (C:\Files).
    When I open (as domain admin with UAC elevated permissions) on my DB server SQL Management studio, I can browse tables and everything works.
    The problem is, if I open SQL management studio (as domain admin with UAC elevated permissions) on my File server or any other computer, when trying to browse my linked server i got error:
    TITLE: Microsoft SQL Server Management Studio
    Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
    ADDITIONAL INFORMATION:
    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
    Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Synesis_3PRO2013". (Microsoft SQL Server, Error: 7303)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.00.3000&EvtSrc=MSSQLServer&EvtID=7303&LinkId=20476
    When I try to place simlpe Select SQL query I got error:
    OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "MyLinkedServer" returned message "The Microsoft Access database engine cannot open or write to the file '\\myfileserver.mydomain.com\files\mydatabase.mdb'. It is already opened exclusively by another
    user, or you need permission to view and write its data.".
    I do not have any other program using my access database, and user has full control. I am trying to use in security mode - "For a login not defined in the list above, connections will be made without using a security context", i have also tried all four options.
    I am confused becouse it works from SQL server but from any SQL client domain member computer/server it does not work.
    I have same problem in another environment where I have Windows Server 2008 R2 and SQL 2008 R2 SP2.
    Please help.
    -- Hrvoje Kusulja

    NTFS must be fine since it works from same server using same accounts.
    As I understand, adding my access file to Access trusted location could be a problem. I have tried now to add my access database file location to trusted locations for user which is my SQL service user (Windows Service - AD managed service account MYDOMAIN\SQL1$)
    and my test user which I use to connect to sql server as a client from sql management studio. (Account is Domain Admins and have full permissions on SQL server also)
    I have added this .reg:
    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security]
    [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Documents]
    "LastPurgeTime"=dword:01592874
    "DisablePromptOpenNetworkTrustedDocuments"=dword:00000000
    [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations]
    "AllowNetworkLocations"=dword:00000001
    [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location0]
    "Description"="My file server"
    "AllowSubFolders"=dword:00000001
    "Path"="\\\\myfileserver.mydomain.com\\files\\"
    I have done this for SQL service account user and my personal test account as I said. I have tried to logoff and restart sql service and all servers also.
    The same problem still persists.
    Anyway, thank you for giving me a hint.

  • What is the difference between partner function and partner type

    Hi Gurus,
    What is the difference between partner function and partner type?
    Thanks,
    Paul

    Hi John,
    The partner types allow us to distinguish between different business partners such as customer, vendor, employee etc and the partner functions represent the functionality or role each partner plays within the business transaction.
    For example under the partner type Customer, you will find - Sold to party, Ship to party, Bill to party, Payer.
    The business partners that exist in the market place are represented with a partner type in the R/3 system. Examples of business partners are customer, vendor, employee and contact person.
    The following partner types are defined in the partner processing for the sales & distribution module –
    a.     AP – contact person (06)
    b.     KU – customer (07)
    c.     LI – vendor (08)
    d.     PE – employee/personnel (09)
    Assigning the partner functions in the SAP system determines the functions of particular partner in the sales process. One partner may take on several functions also.
    REWARD POINTS IF HELPFUL
    Regards
    Sai

  • "RUN-TIME ERROR '3078': The Microsoft Access database engine cannot find the input table or query 'name'. Make sure it exists and that its name is spelled correctly.

     When I run the code below I get the following error:"RUN-TIME ERROR '3078': The Microsoft Access database engine cannot find the input table or query 'False'. Make sure it exists and that its name is spelled correctly. Note that I do not call
    anything by the name of "false" anywhere in this code.
    The subject code (the underscored line of code is highlighted in the debugger when the error occurs):
    Option Compare Database
    Private Sub JobAssign_Click()
    MatLotListAvail_openform
    End Sub
    Function MatLotListAvail_openform()
    Dim dbsAPIShopManager2010 As DAO.Database
    Dim rstMaterialLotJobJoint As DAO.Recordset
    Dim strSQL As String
    Set dbsAPIShopManager2010 = CurrentDb
    strSQL = "SELECT * FROM MaterialLotJobJoint WHERE JobID" = "tempvars!JobID" And "MatLotID" = "tempvars!MatLotID"
    Set rstMaterialLotJobJoint = dbsAPIShopManager2010.OpenRecordset(strSQL, dbOpenDynaset)
    If rstMaterialLotJobJoint.EOF Then
    DoCmd.OpenForm "JobAssignMatConf", acNormal, "", "", acEdit, acNormal
    Forms!JobAssignMatConf!PartapiIDVH = TempVars!PartapiID
    Forms!JobAssignMatConf!JobapiIDVH = TempVars!JobapiID
    Forms!JobAssignMatConf!JobIDVH = TempVars!JobID
    Forms!JobAssignMatConf!MaterialLotIDVH = TempVars!MatLotID
    Forms!JobAssignMatConf!Desc = TempVars!MatDesc
    Forms!JobAssignMatConf!recdate = TempVars!recdate
    DoCmd.Close acForm, "MaterialLotListAvailable"
    Else: MsgBox "This material lot has already been assigned to this job."
    DoCmd.Close acForm, "MaterialLotListAvailable"
    End If
    End Function

    I think the SQL statement should be
    strSQL = "SELECT * FROM MaterialLotJobJoint WHERE JobID=" & _
    tempvars!JobID & " AND MatLotID=" & tempvars!MatLotID
    This assumes thatJobID and MatLotID are number fields.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • What is ESOA? What is the Scope/Role for Functional Consultants in eSOA.

    Hi Experts,
    1)     Does eSOA is a tool, application or module?
    2)     What is the relation between eSOA and ECC6.0?
    3)     What is the Scope/Role for Functional Consultants in eSOA?
    4)     What I have to learn in eSOA?
    5)     How it is useful for Functional Consultant?
    6)     How it is useful for Customers?
    7)     How much time it will take to learn eSOA?
    8)     Where can get the Material?
    9)     What all technologies I have to learn before I learn  to eSOA?
    I am working as a SAP HR Consultant. If I want to learn eSOA what are the pre-requisites.
    I donu2019t know anything eSOA.
    Please give me the answers.
    Regards,
    Ram

    Hi Ram,
    See the answers below
    > 1)     Does eSOA is a tool, application or module?
    ESOA is not any tool,application or module. Its a methodology/Architecture
    > 2)     What is the relation between eSOA and ECC6.0?
    ECC 6.0 provides some Enterprises Services through enhancement packages.
    > 3)     What is the Scope/Role for Functional Consultants in eSOA?
    FUnctional consultant should know which ENterprise Serrvices are available and which should be developed to carry out a business process.
    > 4)     What I have to learn in eSOA?
    .         Being a technical guy, there are things to be learnt like ESR, implementing designed serivces through ABAP or Java and consuming it. But being a functional guy, only awareness of what enterprise services are available and what they do and their input/output params and how they can fit into a business process is sufficient.
    > 5)     How it is useful for Functional Consultant?
    see above
    > 6)     How it is useful for Customers?
    Customers can move towards Service Oriented Architecture, get flexibility in changing a business process easily, maintaince cost is less
    > 7)     How much time it will take to learn eSOA?
    depends on your skills
    > 8)     Where can get the Material?
    lot of material in SDN
    > 9)     What all technologies I have to learn before I learn  to eSOA?
    ABAP or JAVA,ESR ( being a technical consultant) , Web Services
    > I am working as a SAP HR Consultant. If I want to learn eSOA what are the pre-requisites.
    you should aware of basics of service oriented architecture
    If you further want to clear doubts, do write up.
    Regards,
    Piyush

  • What is the Diff bet partner functions and business partner?

    Hi friends
    what is the Diff bet partner functions and business partner
    Regards
    Abirath

    Hi,
    In SRM there are different Partner functions like REQUESTER, GOODS RECIPIENT, VENDOR ,LOCATION.
    All the org units or users in SRM will have a unique identification number called Business Partner Number maintained in table BUT000.
    The users can have differnt partner functions in differnt documents and accordingly mainatained in table CRMD_PARTNER.
    Hope this will give you some infomation.
    Regards,
    Sheetal.

  • What is the purpose of queue functions?

    well what is the relation of queue functions of Labview
    and queuing theory, like MM1 system MD1 system etc.
    thanks

    Others may have a better explanation and example, but I have found that queues in LabView are very useful when you need to transfer a lot of information quickly and want to make sure you don't overflow or drop elements. They are better at this than using variables because the writer can keep writing whether or not the reader has read the last element. 
    For instance, recently we were trying to record data on a cRIO device and get the fastest rates possible. We were recieving data from the FPGA FIFO and writing directly to file. When you try to record 32 channels of 32 bits/element at 1 kHz you begin to test the limits of your write to file function. Queues worked better than variables for this because every so many cycles the write function would sort of hiccup and pause, causing the elements in the queue to increase (backup). If we were using regular variables we would have had to wait for the recording to catch up before we could continue reading data. This would mean we would be overflowing the FIFO or missing data points. However, with a queue, elements could back up a little and then the record function would catch up. (As a side note, write to binary file worked faster than TDMS in these benchmark experiments.)
    Can anyone explain it better?
    [will work for kudos]

  • What is the iphone's first aid specs incase it got soaked in water acciedentaly ??

    what is the iphone's first aid specs in case it got accidently soaked in water??

    As I said it will lock to the first UK sim inserted .There is a chance as you appear not to have yet put in a UK sim it is not actually locked  but is useless outside the UK as it is looking for a UK carrier .
    It is also not clear how it  would lock to Tigo and then not function
    You could try contacting Apple if they have a contact in Columbia .
    Apple care may tell you if and to whom the iPhone is locked to and then all you can do
    is see the carrier's  criteria for unlocking assuming they do
    http://www.apple.com/support/country/

  • My icloud account was hacked. what can the hacker access? text messages? texts back ups?

    My icloud account was hacked. what can the hacker access? text messages? texts back ups?

    yahoo does not have strong security, they hacked my yahoo account first then they got to my icloud email. I have backed up my Iphone 4 using icloud storage under icloud option, still wondering how they can access my text though?

  • What is the mac pro reset function key?

    what is the mac pro reset function key?

    Sorry, but what "reset function key" are you referring to? What is it you wish to reset?

Maybe you are looking for

  • Retrieve data from a string.

    I want to write a SQL script to retreive data between the third "|" and the forth "|" from a string: Example: String = 'H000319|VI|12|20000|20000|4201840007403429,09/2008,442667,,|' The result should be 20000. String = 'H000319|HK|0|11860|11860||' Th

  • Mac Mini server not showing second hard drive

    early 2009 mini server suddenly won't show the second hard drive for time machine. All I get in the system profiler is this? Is my hard drive toast or is there any idea out there of how to recover it? Thanks for the help! Running 10.6.8 server by the

  • The dowload of firfox will not move past the run screen

    I have been trying to install Firefox to my desktop. The dowload will not progress past the run screen. There is no set up. I successfully installed on my second computer so I am confused.

  • Import Java Classes impossible?!

    Hello all! I tried in Forms 6i to use the option "import Java Class". But i always get the error-message PDE-UJI001, which I didn't find in any documentation. This error occurred on two different systems, in Win2000 and Win98. null

  • Windows XP Home

    I have read through a lot of these complaints, and so far, just about everyonw having these problems installing have Windows XP home. Again, I will say that the Windows XP Home version that I have is an Upgrade OS and I had NO problems installing Jav