Get Latest Entry for each Item

I have a table that has items with multiple entries per item.  Each entry has a date of when it was entered.  I want to get unique entries with the latest date. For example,
From this:
item
date
item1 12/13/2014
item1 12/15/2014
item2 12/10/2014
item2 12/19/2014
To this:
item
date
item1 12/15/2014
item2 12/19/2014
Thanks in advance.

Give this a try:
DECLARE @items TABLE (itemName VARCHAR(20), itemDate DATE)
INSERT INTO @items (itemName, itemDate) VALUES ('item1', '12/13/2014'),('item1', '12/15/2014'),('item2', '12/10/2014'),('item2', '12/19/2014')
SELECT *
FROM @items i
WHERE i.itemDate = (
SELECT MAX(itemDate)
FROM @items
WHERE i.itemName = itemName

Similar Messages

  • The operation can't be completed because some items had to be skipped. For each item, choose File Get Info, make sure "Locked" is deselected, and then check t

    The following error comes up when I try to install the updated Firefox:
    "The operation can’t be completed because some items had to be skipped. For each item, choose File > Get Info, make sure “Locked” is deselected, and then check the Sharing & Permissions section. When you are sure the items are unlocked and not designated as Read Only or No Access, try again."
    When I follow the instructions in the error message, it shows that my user name has read and write access. There are a couple other items that are read only. I tried to change this to read and write, but the Sharing and Permissions options are greyed out and will not let me change them. What is the work around for this? I would really like to install the new firefox.
    Thanks.

    Hello,
    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default('''This will NOT delete profile info such as bookmarks and history'''):
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thank you.

  • External ID (SSCC / EXIDV) for each item inside a heterogeneous pallet

    Hello experts,
    I need to generate an external ID (SSCC code) to each item (box) inside a multi-product HU(pallet) in my system.
    In normal operation, my system picks up a delivery and packs it, creating standard HUs (one fixed quantity of one material), and/or heterogeneous Hus (non-standard quantities of one or more materials) inside a pallet for each item in the delivery. Each pallet (HU) created has an entry in VEKP table and a distinct SCCC stored in field EXIDV. Iu2019m using shipping materials of type pallet.
    If I need a different SSCC to each BOX inside the non-standard pallet, what is the better approach?
    -     Create shipping a material with type BOX
    -     For each HU created, unpack it using BAPI_HU_UNPACK
    -     For each BOX inside the initial HU, create a shipping material type BOX with a new EXIDV (SSCC), and pack inside it a box, and then pack this shipping material back into the initial HU?
    To have one EXIDV for each box, I canu2019t group (sum) the quantities even if they correspond to a some material.
    This seems to me the only way to solve this problem, but it will be a hard work.
    Can someone point a simplest way to turn around this problem?
    Thank you
    Best regards
    Paulo Sousa

    I kept researching, I found some possible solution in this blog:
    https://blogs.oracle.com/xmlpublisher/category/Oracle/Templates/RTF
    so, I created a local SITE variable inside every cell to get the external SITE info:
    <Cell>
    <xsl:variable name="DIMID" select="DIMID"/>
    <xsl:variable name="SITE" select="{xdoxslt:get_variable($_XDOCTX,'SITE')}"/>
    <xsl:value-of select="/DATA/SITE/SITE_DATA[DATAGROUPID = $SITE]/YEAR[SURVEYYEAR = 2012]/DIM[DIMID = $DIMID]/ITEM[ITEMID = 0 and PUNFAV != 0]/PFAV"/>
    </Cell>
    but I get this error at run time:
    oracle.xdo.parser.v2.XPathException: Error in expression: '{xdoxslt:get_variable($_XDOCTX,'SITE')}'.
        at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
        at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)
        ... 14 more
    What am I doing wrong?

  • Qry:How to get different price for each price list (variable area) in order

    1-How to get different price for each price list (variable area) in order for sale. for the opportunity to display and select multiple prices.
    2- I add a location store from a table in line item and I want to see this area in order,.
    I 'm created 2 field location(item line and order), 1 table location
    I tried this for exemple : select $ [userfieldlocation.OITW]

    Thanks Suda for your answer,
    the Formatted Search for prices is OK, but for the Item locations in warehouse this is not so simple,     
    I must have several (at least 2) locations for the item in the Warehouse and a track of this location and search possibilities.
    read carefully and imagine how (Management warehouse locations)
    I added a user table '@Location' who linked to a user field 'U_Location in Item master data --> lnventory data  line and an ather user field 'U_Location' in sales order
    I met the value of location in the table (list of locations for any warehouse), I select the location of each item while receiving merchandise in the user field of inventory data line (Item M data) and this value appears in the sales order 'U_Location' user field ( only the location value in the default warehouse for this Item)
    or
    create an user field 'location' in Good receipt PO to fill it while receiving merchandise that appears in the sales order to give possibility to find/select the location of the item at this order and in Item master data
    I think we will use all these tables
    @LOCATION
    PDN1
    OITM
    OITW
    OWHS
    RDR1
    Juste a another question : where you found this and What is: ' 38.1.0 '
    Is it in document (System information):Item=38 Pane=1 ??
    Thanks,
    Ouchen

  • Itunes has stopped working and iphone calendar has 10 entries for each event

    "itunes has stopped working", since I tried an update which failed.
    Also when I plugged in my iphone it went straight to restore and not only lost all my recent stuff as you might expect - annoying enough, but has installed at least 10   entries for each event. How do I get rid of them? Tried deleting the event but it doesn't take away every single entry. (And can I get my recent stuff back?)
    These are probably diffferent problems but as my name implies I'm a complete numpty when it comes to the technical terms so please, in lay terms, what should I do?

    Well I seem to have solved this myself...Much to my surprise!
    First the itunes issue. When the itunes update screen came up again it said if you have trouble with this go to Tools (top of itunes panel) and press "download only" which I did and the rest just sort of happened. It uninstalled and then installed.. All I had to do was open each file. Checked my stuff and all there. Checked itunes store and straight in.
    Iphone calendar. Not sure how this happened but it had about 25 - 30 copies of each event. I went through each calendar and by process of elimination deleted the ones that seemed to be causing the problem. I didn't lose any events but all of a sudden there was only one each of them. Bizzaire but true.
    This is a very rare day for me. A Good IT Day.

  • Change fpla-rfpln for each item in the user_exit_move_field_to_fpla

    Hi,
    I used VA41 transaction to create a sale order (auart = u201CXXXXu201D) and i would like assign in the u201Cuser_exit_move_field_to_fplau201D a calendar number (fpla-rfpln) in my sale document, for each items line.
    But the program is passed on the u201Cuser_exit_move_field_to_fplau201D only for the configurable post (vbap-posnr = u201800010u2019) !!!!
    How can i do to go in this USER_EXIT for all items line and assign a calendar number? It is possible???
    Thanks
    Titou.

    Hello Titou,
    I don't know for your special case (this transaction) but in a user exit you can have access to global variables by using field-synbols.
    Declare a constant like this:
    constants : c_program3(30) TYPE c VALUE '(NameOfTheProgram)t_data'.
    You can dynamic assign of fiel symbols to get this global variable in your user exit.
    field-symbols : <k> type any,
                    <l> type any.
      ASSIGN c_program3 TO <k>.
      ASSIGN (<k>) TO <l>.
      if <l> is assigned.
      endif.
    So if in your program you have the all your items stored in a global variable, you can then modify all of them.
    Hope it helps.
    Olivier

  • Issue with Report to get Position value for each Class ID.

    Hello Experts,
    m working on a report where I want Position values as on date.
    for an entered date report should give position value(Amount for transaction) for each class Id.
    I m trying using the exit variable but could not reach the output.
    For date I created an exit variable which shoud return the latest position for each class Id.
    Now this exit variable is "ready for Input" . when I debug my code it takes i_step =3 and i_vanm= " " after i_step = 1 and i_vnam = "<variablename>"
    how do I go about to get the solution.
    Guide me to come up with desired output.
    Thanks in Adv.
    Bhavna.

    Hello Experts,
    m working on a report where I want Position values as on date.
    for an entered date report should give position value(Amount for transaction) for each class Id.
    I m trying using the exit variable but could not reach the output.
    For date I created an exit variable which shoud return the latest position for each class Id.
    Now this exit variable is "ready for Input" . when I debug my code it takes i_step =3 and i_vanm= " " after i_step = 1 and i_vnam = "<variablename>"
    how do I go about to get the solution.
    Guide me to come up with desired output.
    Thanks in Adv.
    Bhavna.

  • SD - Accounting document line items are generating for each item

    Hi all of you,
    We have done account determination for SD. Accounting documents are also generating, but with in the invoice accounting document, number of line items are generating for each item with in the sales order, standard invoice type is F2 like -
    Item 001 - X Material
    Item 002 - Y Material
    Item 003 - Z Material
    The accounting document is -
    Line Item 001 - Customer Ac Dr
    Line Item 002 - Discount A/c Dr
    Line Item 003 - Sales revenue
    Line Item 004 - Discount A/c Dr
    Line Item 005 - Sales Revenue
    Line Item 006 - Discount A/c Dr
    Line Item 007 - Sales revenue
    Line Item 008 - VAT
    Even, in my experience I did not find this type of entry and the sales revenue and discount accounts are same with in the COA and is posted with in the plant.
    Please give me your valuable suggestion to rectify the above issue.
    Regards,
    Ramki
    Edited by: Ramki on Nov 5, 2009 10:06 AM

    Dear Ramki,
    This is SAP Standard. System generates Accounting document line item for each Line items in Invoice.
    This is standard & also required bacuase say you have different Material types in single Invoice (e.g.Material & Service items, Trading Goods, etc). The valuation class assigned to these Material Types may be different & you might want to post revenues from these Line items in different GL Accounts.
    Hope this helps. .
    Thanks,
    Jignesh mehta

  • Tree control tip strip for each item

    In tree control is possible set a Tip strip for each item (node) of tree?
    In tree control  tipStrip property seems relative to all tree.
    Thanks all.

    The only thing I can think of is to use an event structure
    use a mouse move event
    Get Cords
    Calculate what item the mouse is over
    Use a Tips property node to write the correct string.
    The hard part will be calculating what item the mouse is over, The Displayed Items property node should help.
    I am actively working on a program that is centered around a tree control and might like to do the same.
    If you need further help reply back 
    Omar

  • Fetching unit_of_meaurement value for each item

    Hi ,.
    I want to fetch the value unit_of_measurement (MSEHI) value from table T006
    for each items
    I havent find any linakage
    How can i read these values for each item
    Thanks
    Anil

    I have a material number say, Grumpy. The report that I have shows the total sales for Grumpy for $13,000.00. Grumpy has other submaterials number says Grumpy_1, Grumpy_3, Grumpy_4, Grumpy_5. The report only shows the total quantity sold for each of these submaterials. Say
    Grumpy_1 = 800
    Grumpy_3 = 70
    Grumpy_4 = 1
    Grumpy_5 = 33
    I want to find a way to get an IO that tells me a price sold for 1 quantity, so that I can use it to find the total sold for Grumpy_1, Grumpy_3, Grumpy_4, Grumpy_5 that will add  to equal $13,000.00
    Thanks
    "<i>Sometimes I need what only you can provide: your absence.</i>" ~ Anonymous

  • Filter Oldest Entry for Each Record

    Post Author: Stephanie
    CA Forum: Desktop Intelligence Reporting
    I have a file that has multiple rows for each record, each with a different date. I would like to filter the report so that only the oldest entry for each record appears. Any suggestions? The report looks like this:
    Record 1     01/01/07
    Record 1     03/01/07
    Record 1     05/01/07
    Record 2     03/01/07
    Record 2     05/01/07
    Record 2     07/01/07
    I would like the report to show this:
    Record 1     01/01/07
    Record 2     03/01/07
    Thank you.

    Post Author: Stephanie
    CA Forum: Desktop Intelligence Reporting
    Thanks for the suggestion, but I had already tried that and I could not get it to work. I made a variable =Min(<Date>). When I removed the other date field, my report did look like this:
    Record 1     01/01/07
    Record 2     03/01/07
    The problem is that there are other fields in the entry that I need to display as well. Let me rephrase what my original file looks like.
    Record 1     01/01/07     Product A
    Record 1     03/01/07     Product H
    Record 1     05/01/07     Product K
    Record 2     03/01/07     Product Z
    Record 2     05/01/07     Product G
    Record 2     07/01/07     Product H
    I want the result to look like this:
    Record 1     01/01/07     Product A
    Record 2     03/01/07     Product Z
    When I use the min formula, I can't figure out a way to get the product information from the original record as well.

  • Equal Number Of Entries For Each Group

    Hi,
    I have been working on the problem off and on for a couple of weeks. I posted a simplified version of the question earlier and got good answers but the problem was not in the answers but how I asked the question.
    My issue is this: I have a large data set with many dimensions. One of those dimensions is line number. The way the data is enter if the value for line number is zero there is no entry for that line number. So say California has 40 line numbers and Alaska has 3. This layout will not work for a project we are doing. What we need it to have the same number of line entries for each dimensions. So California would have 140 line entries with zeros for the blank entries and Alaskia would also have 140 line entries with zeros for the blank entries.
    I'm using Toad and Oracle 10

    Hi,
    Sure, you can do that. Outer-join a table (or result set) that has 140 rows to your real table.
    Here's an example of a sub-query that has 140 rows:
    WITH    cntr  AS
        SELECT  LEVEL   AS n
        FROM    dual
        CONNECT BY  LEVEL  <= 140
    ) ...Later in the query, you can reference cntr as if it were a table. cntr.n will have the values 1, 2, 3, ..., 140.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data. Simplify the problem as much as possible. For example, instead of needing 140 rows (when the actual data has only 3 or 40), say you want 4 rows, and post data that has 1 or 3 rows. You can change the numbers easily after you understand the solution.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • HT204085 why do I have to re-type the password for each item, like contacts, messages etc. every time I restart the computer?

    Every time I start up the computer I get a pop up to type in my keychain password for each item. One for contacts and again for messages etc. Why do I have to do this every time at startup?

    Hello, GoodyearMary. 
    Thank you for the question.  Here are a couple articles that you may find helpful with this issue.
    OS X: Keychain Access asks for keychain "login" after changing login password
    http://support.apple.com/kb/HT1631                 
    OS X Mavericks v10.9.1: Repeated prompts to unlock "Local Items" keychain
    http://support.apple.com/kb/TS5362
    Regards,
    Jason H.

  • How to Get Missing Dates for Each Support Ticket In My Query?

    Hello -
    I'm really baffled as to how to get missing dates for each support ticket in my query.  I did a search for this and found several CTE's however they only provide ways to find missing dates in a date table rather than missing dates for another column
    in a table.  Let me explain a bit further here -
    I have a query which has a list of support tickets for the month of January.  Each support ticket is supposed to be updated daily by a support rep, however that isn't happening so the business wants to know for each ticket which dates have NOT been
    updated.  So, for example, I might have support ticket 44BS which was updated on 2014-01-01, 2014-01-05, 2014-01-07.  Each time the ticket is updated a new row is inserted into the table.  I need a query which will return the missing dates per
    each support ticket.
    I should also add that I DO NOT have any sort of admin nor write permissions to the database...none at all.  My team has tried and they won't give 'em.   So proposing a function or storable solution will not work.  I'm stuck with doing everything
    in a query.
    I'll try and provide some sample data as an example -
    CREATE TABLE #Tickets
    TicketNo VARCHAR(4)
    ,DateUpdated DATE
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-01')
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-05')
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-07')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-03')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-09')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-11')
    So for ticket 44BS, I need to return the missing dates between January 1st and January 5th, again between January 5th and January 7th.  A set-based solution would be best.
    I'm sure this is easier than i'm making it.  However, after playing around for a couple of hours my head hurts and I need sleep.  If anyone can help, you'd be a job-saver :)
    Thanks!!

    CREATE TABLE #Tickets (
    TicketNo VARCHAR(4)
    ,DateUpdated DATETIME
    GO
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-01'
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-05'
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-07'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-03'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-09'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-11'
    GO
    GO
    SELECT *
    FROM #Tickets
    GO
    GO
    CREATE TABLE #tempDist (
    NRow INT
    ,TicketNo VARCHAR(4)
    ,MinDate DATETIME
    ,MaxDate DATETIME
    GO
    CREATE TABLE #tempUnUserdDate (
    TicketNo VARCHAR(4)
    ,MissDate DATETIME
    GO
    INSERT INTO #tempDist
    SELECT Row_Number() OVER (
    ORDER BY TicketNo
    ) AS NROw
    ,TicketNo
    ,Min(DateUpdated) AS MinDate
    ,MAx(DateUpdated) AS MaxDate
    FROM #Tickets
    GROUP BY TicketNo
    SELECT *
    FROM #tempDist
    GO
    -- Get the number of rows in the looping table
    DECLARE @RowCount INT
    SET @RowCount = (
    SELECT COUNT(TicketNo)
    FROM #tempDist
    -- Declare an iterator
    DECLARE @I INT
    -- Initialize the iterator
    SET @I = 1
    -- Loop through the rows of a table @myTable
    WHILE (@I <= @RowCount)
    BEGIN
    --  Declare variables to hold the data which we get after looping each record
    DECLARE @MyDate DATETIME
    DECLARE @TicketNo VARCHAR(50)
    ,@MinDate DATETIME
    ,@MaxDate DATETIME
    -- Get the data from table and set to variables
    SELECT @TicketNo = TicketNo
    ,@MinDate = MinDate
    ,@MaxDate = MaxDate
    FROM #tempDist
    WHERE NRow = @I
    SET @MyDate = @MinDate
    WHILE @MaxDate > @MyDate
    BEGIN
    IF NOT EXISTS (
    SELECT *
    FROM #Tickets
    WHERE TicketNo = @TicketNo
    AND DateUpdated = @MyDate
    BEGIN
    INSERT INTO #tempUnUserdDate
    VALUES (
    @TicketNo
    ,@MyDate
    END
    SET @MyDate = dateadd(d, 1, @MyDate)
    END
    SET @I = @I + 1
    END
    GO
    SELECT *
    FROM #tempUnUserdDate
    GO
    GO
    DROP TABLE #tickets
    GO
    DROP TABLE #tempDist
    GO
    DROP TABLE #tempUnUserdDate
    Thanks, 
    Shridhar J Joshi 
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Get the Count for each row

    I'm trying to get the count for each row to total count for each month
    Something like this
    Hardware     |      Jan
    Monitors       |       5
    Processors   |      137
    Printers        |      57
    etc........
    How can I write a query for this. I can get the Hardware column but don't know how to get the next column.

    If you can provide more data like sample input DML statements it would have been wonderful..
    Assuming is , you need a pivot. Here is an article on basic Pivot..
    http://sqlsaga.com/sql-server/how-to-use-pivot-to-transform-rows-into-columns-in-sql-server/
    something like this may be..
    DECLARE @Input TABLE
    Hardware VARCHAR(20),
    [Date] VARCHAR(20)
    INSERT INTO @Input VALUES('Monitor', '01/01/2014'), ('CPU', '01/01/2014'), ('Monitor', '01/03/2014')
    , ('ABC', '01/01/2014'),('Monitor', '02/01/2014')
    ;WITH CTE AS
    SELECT Hardware, LEFT(DATENAME(M, [Date]),3) AS [MonthName] FROM @Input
    SELECT *
    FROM
    SELECT Hardware, [MonthName], COUNT(Hardware) AS Count FROM CTE GROUP BY Hardware, [MonthName]) a
    PIVOT (MAX([Count]) FOR [MonthName] IN ([Jan], [Feb])) pvt
    Please mark as answer, if this has helped you solve the issue.
    Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

Maybe you are looking for