Query for last four rows?

please write query for get the last four rows from a table

ratnakar wrote:
please write query for get the last four rows from a tablelast 4 rows is indeterminate.
rows in a table are like balls in a basket.
which are last 4 balls in any basket?
Handle:     ratnakar
Email:     [email protected]
Status Level:     Newbie
Registered:     Aug 27, 2012
Total Posts:     34
Total Questions:     16 (11 unresolved)
why so MANY unanswered questions?

Similar Messages

  • Query for last  n rows please

    Hi All,
    Can anybody give me a SQL Query which will select last n rows from a table.
    guess some time I see this query in this forum but forgot to note it down.
    Thanks in Advance
    [email protected]

    Hi All,
    There is a simple solution, which will be useful at some of the following cases.
    1) Find Top( or bottom) <n> rows.
    For e.g. Top 5 rows or Bottom 100 rows.
    2) Range of rows.
    For e.g. Row 11 to row 20. (which is required for displaying the dynamic pages on web search engines)
    We need to understand how Oracle processes the query.
    SQL>Select rownum, Ename, Sal from Emp;
    ROWNUM ENAME SAL
    1 A 1000
    2 B 800
    3 C 3500
    But, if we write the query in following manner, check the output to understand Oracle's query processing.
    SQL>Select rownum, Ename, Sal from Emp order by Sal;
    ROWNUM ENAME SAL
    2 B 800
    1 A 1000
    3 C 3500
    The above output makes it clear that the rownum is assigned to the array of output before sorting it.
    Therefore, if you have to use the rownum of sorted output, you will have to use the inline query.
    SQL>Select rownum, Ename, Sal from (Select Ename, Sal from Emp ) order by Sal;
    ROWNUM ENAME SAL
    1 B 800
    2 A 1000
    3 C 3500
    The above query can be used, but not for any kind of filter conditions. Please check the tricky part of this filter condition.
    SQL>Select rownum, Ename, Sal from (Select Ename, Sal from Emp ) order by Sal
    where rownum = 2;
    No rows returned.
    This is because the rownums are generated first, then the filter is applied for Each row.
    Therefore, if the rownum is 1 it is filtered out. Therefore, the second row becomes first row( rownum = 1) and again it gets filtered out.
    Therefore, here we need to use one more inline query.
    SQL>Select rnum, Ename, Sal from (
    Select rownum rnum, Ename, Sal from (Select Ename, Sal from Emp ) order by Sal)
    where rnum = 2;
    ROWNUM ENAME SAL
    2 A 1000
    Think, with this above discussion, you can generate any type of query.
    Regards.
    Yogesh D.

  • Query for last 8 days results

    any body have a query for last 8 days results
    TIMESTAMPADD(SQL_TSI_DAY, -8, CURRENT_DATE) this is resulting only 1 day results only .if i execute this query is it displaying 8th back day results only.
    i want all 8 back days results .
    anybody have query for this...
    Edited by: user12255470 on Apr 28, 2010 7:19 AM

    This works fine for me:
    SELECT "D0 Time"."T00 Calendar Date" saw_0, "F1 Revenue"."1-01 Revenue (Sum All)" saw_1 FROM "Sample Sales" WHERE "D0 Time"."T00 Calendar Date" BETWEEN TIMESTAMPADD(SQL_TSI_DAY, -8, CURRENT_DATE) AND TIMESTAMPADD(SQL_TSI_DAY, -1, CURRENT_DATE) ORDER BY saw_0
    regards
    John
    http://www.obiee101.blogspot.com/

  • How to find top utilized query for last two months in oem

    how to find top utilized query for last two months in oracle enterprise manager?

    Can you mark the thread as Helpful  and once marked the information can be reviewed by other customer for similar queries
    Regards
    Krishnan

  • This ipad hasb't been backed up in 6weeks. Backups happen when this iPad is plugged in , locked, and connected to wi-fi. i see this message in my ipad for last four days. i can't get out of it. i can't slide to power off on the sreen

    i have recieved the message on my iPad: This ipad hasb't been backed up in 6weeks. Backups happen when this iPad is plugged in , locked, and connected to wi-fi. i see this message in my ipad for last four days. i can't get out of it. i can't slide to power off on the sreen. the touch screen is locked. So i can't do anything eithere switch off or reset. kindly advice me.

    Try this support article >  iOS: Not responding or does not turn on

  • Query for last 5 Purchase Price for items

    Dear All
    I was trying to write a query in which
    i want to display Items with last 5 purchase price
    itemcode     UOM      Last Purchase Price        II Last Pur Price       III Last Pur Price        IV Last Pur Price         V Last Pur Price
    but not getting right result because of future posting and post date entries as I am considering Max(DocNum) for Query.
    SELECT distinct a.ItemCode, a.invntryUom
    , (select Price from PCH1 where itemcode=a.itemcode and
    docentry=(select max(docentry) from PCH1 where itemcode=a.ItemCode)) as 'II Pur. Price'
    , (select Price from PCH1 where itemcode=a.itemcode and
    docentry=(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode))) as 'II Pur. Price'
    , (select Price from PCH1 where itemcode=a.itemcode and
    docentry=(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode)))) as 'III Pur. Price'
    , (select Price from PCH1 where itemcode=a.itemcode and
    docentry=(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode))))) as 'IV Pur. Price'
    , (select Price from PCH1 where itemcode=a.itemcode and
    docentry=(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode and docentry<(select max(docentry) from PCH1 where itemcode=a.ItemCode)))))) as 'V Pur. Price'
    , Max(b.docentry) as 'MaxDocEntry'
    FROM OPCH INNER JOIN
    PCH1 b ON OPCH.DocEntry = b.DocEntry INNER JOIN
    OITM a ON b.ItemCode = a.ItemCode
    group by a.ItemCode, a.invntryUom
    order by a.ItemCode
    Please help me on this.
    Regards
    Anubha Paliwal

    Hi........
    Try this......
    SELECT Top 5 T0.[DocNum], T1.[ItemCode], T1.[Dscription], T1.[Price], T3.[ItmsGrpCod],
    T3.[ItmsGrpNam] FROM OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON
    T2.ItmsGrpCod = T3.ItmsGrpCod WHERE T3.[ItmsGrpNam] ='[%0]' ORDER BY T0.[DocDate] desc
    Regards,
    Rahul

  • VStest.console.exe Query for a Data Row Result DURING Test Execution Status

    I started with the following
    thread and was asked to create a new thread. 
    I have the following test that reads a .csv as a data source.
    /// <summary>
    /// Summary description for Test
    /// </summary>
    [TestCategory("LongTest"),
    TestCategory("Visual Studio 2013"), TestMethod]
    [DeploymentItem("data.csv")]
    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV",
    "|DataDirectory|\\data.csv",
    "data#csv",
    DataAccessMethod.Sequential),
    DeploymentItem("data.csv")]
    public void Create_And_Build_All_Templates()
    testmethodname = "Create And Build All Templates ";
    LaunchVisualStudio2013();
    When I run the test from VStest.console.exe, I see the following:
    vstest.console.exe /testcasefilter:"TestCategory=LongTest" /settings:"C:\testing\CodedUI.testsettings" /logger:TRX /logger:CodedUITestLogger C:\AppTests\CodedUITest.dll
    Microsoft (R) Test Execution Command Line Tool Version 12.0.31101.0
    Copyright (c) Microsoft Corporation. All rights reserved.
    Running tests in C:\testing\bin\debug\TestResults
    Starting test execution, please wait...
    I want to report on the status of the iterations DURING the test run from VStest.console.exe, like how the test explorer window does this. 
    How can I achieve the output below (notice the (Data Row ) values) ?
    vstest.console.exe
    /testcasefilter:"TestCategory=LongTest"
    /settings:"C:\testing\CodedUI.testsettings"
    /logger:TRX
    /logger:CodedUITestLogger
    C:\AppTests\CodedUITest.dll
    Microsoft (R) Test Execution Command Line Tool Version 12.0.31101.0
    Copyright (c) Microsoft Corporation. All rights reserved.
    Running tests in C:\testing\bin\debug\TestResults
    Starting test execution, please wait...
    Test Passed - Create_And_Build_All_Templates (Data Row 1)
    Test Passed - Create_And_Build_All_Templates (Data Row 2)
    Test Failed - Create_And_Build_All_Templates (Data Row 3)
    Test Passed - Create_And_Build_All_Templates (Data Row 4)
    Ian Ceicys

    Jack, again the results are printed to the std. out console AFTER the test data row has been completed. Is there a way to query VSTest.console and find out which test\data row is being executed so it can be written out to the console
    DURING the test run? 
    I put together the following screencast showing the issue: 
    http://www.screencast.com/t/IrxxfhGlzD
    Also here is the github repo with the source code that I included in the screen cast:
    https://github.com/ianceicys/VisualStudioSamples2015
    Take a look at LongRunningDataDrivenTest.sln
    Unit Test
    [TestClass]
    public class UnitTest
    public static int _executedTests = 0;
    public static int _passedTests = 0;
    public void IncrementTests()
    _executedTests++;
    public void IncrementPassedTests()
    _passedTests++;
    [TestInitialize]
    public void TestInitialize()
    IncrementTests();
    Console.WriteLine("Total tests Row executed: {0}", _executedTests);
    [TestCleanup]
    public void TestCleanup()
    if (TestContext.CurrentTestOutcome == UnitTestOutcome.Passed)
    IncrementPassedTests();
    Console.WriteLine("Total passed tests: {0}", _passedTests);
    private TestContext testContextInstance;
    /// <summary>
    /// Long Running Test
    /// </summary>
    [TestCategory("Long Running Test Example"),TestMethod]
    [DeploymentItem("data.csv")]
    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV",
    "|DataDirectory|\\data.csv",
    "data#csv",
    DataAccessMethod.Sequential),
    DeploymentItem("data.csv")]
    public void LongRunning_TestMethod_Takes_Over_30_Seconds_to_Run()
    WaitTime(Convert.ToInt32(TestContext.DataRow["WaitTime"].ToString()));
    public void WaitTime (int waittime)
    Thread.Sleep(waittime);
    public TestContext TestContext
    get { return testContextInstance; }
    set { testContextInstance = value; }
    data.csv
    WaitTime,
    13000
    19000
    10000
    11000
    15000
    Ian Ceicys

  • WQL Query for Last Policy Request

    I'm trying to create a collection based on workstations whose last policy request was more than 30 days ago and I'm having trouble with the query statement.  Any help would be greatly appreciated.

    You can query v_CH_ClientSummary to get last policy request and join
    v_r_system in order to get the comuter name.
    That SQL and cannot be used for building a collection ... 
    Torsten Meringer | http://www.mssccmfaq.de

  • Query for Last page visit by user/session and get version # of current page

    Hi Guru's,
    Any have a query to retrive last page visited by user / session? Somewhere from apex view fir 3.0 or later version? Also looking for query to get version number of current page

    RequestCtx.getResponsibilityId() should return you the Responsibility Id &
    RequestCtx.getUserId() should return the User Id.
    As I understand RequestCtx values are always available in the JSP Page. Kindly check again.

  • Query for Last Communicated Time

    Hi Folks,
    I've searched the forums and I think it may be out there, but I can't find it. Simply put, I'm looking for a WQL query to list all client systems that have communicated with the SCCM server in the last 1 month (or 30 days).
    I have tried { SMS_R_System.LastLogonTimestamp < DateAdd(dd,-30,GetDate()) }, but it is not accurate.
    The "Last Activity" column/criteria looks promising, but I can't find the code to use it.
    Any help in this matter would be appreciated.
    -Bill

    Why not using the build in report: Clients that have not reported recently (in a specified number of days) 
    More information in the following thread:
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/57d0a157-e7d4-40a7-93c7-24ce152afcb2/looking-for-a-report-for-sccm-client-last-contact?forum=configmgrai
    Please take a moment to Vote as Helpful and/or Mark as Answer where applicable. Thanks.

  • FDM Scripting Query for last imported source file using Batch Processing

    Hi Experts,
    I'm currently in the processing of automating the FDM load process on our version of FDM 9.3.3 using batch processing and the FDM Task Manager. Most of the process works fine including an email alert which notifies users of when a data load has taken place.
    As part of that email alert I am trying to attach the source file that has been loaded in batch processing. I have managed to get an attachment using the following FDM Script Object of:
    "API.MaintenanceMgr.fPartLastFile(strLoc, True, False)".
    But have noticed that using this only attaches the last "manually" imported file rather than the last file imported using the batch processing.
    My question is: Is it possible for someone to steer me into the right direction of either a more appropriate API or if I have missed a step in my script.
    Any help as always would be much appreciated.
    Cheers
    Pip

    Unfortunately the batch process does not work the same way as on-line. I am assuming you are using the normal batch load and not Multiload (although the batch is simisar).
    the batch file name gets recorded on the tBatchContents table, and moved to the import/batches folder under the folder for the current batch run. However, if successful the file gets deleted (and from memory does not get archived). To add the import file to the e-mail, after a successful load, i think you will need to store a copy of it prior to importing the file.

  • How to Query for last updated data in planning Cube?

    Hi,
    i want to see the last updated data with specific timestamp on one of our planning application Cube, IS it possible ?
    I have gone through application log and essbase server log but didn't get much information
    Can any one please let me know.
    Thx

    How was the data updated, if it was through planning then you can enabling data auditing and you should be able to then query the information.
    If it is was a data load then in EAS go the database, edit properties, modications, it should display data load information.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Query for how to display unique rows in a table

    Can i have a query for displaying unique rows in a table.

    use d query
    select distinct col1,col2... from table ;

  • My app status is "inreview" for last 4 days.

    I have uploaded my app using itunes connect after 7 days my app got reviewd but they rejected my app and displayed the status like metadata rejected. According to resoltion centre i have given specific info for review and resubmitted without adding new binary.Within hour my app status changed to "In review " but my app not reviewd yet now.It's in same status for last four days.What i need to do now? Is any way to get the reason of delay from apple?

    Hi, LTKS. 
    Thank you for visiting Apple Support Communities. 
    Try removing the preference to sync calendar events in iCloud preferences.  Once this is down enable the preference again and see if this resolves the issue. 
    Turn iCloud Calendars off and back on:
    Quit Calendar (or iCal).
    Choose Apple () menu > System Preferences, then select iCloud.
    Deselect the checkbox next to Calendars.
    Close System Preferences and wait about a minute.
    Open System Preferences and select iCloud.
    Replace the checkmark next to Calendars.
    Close System Preferences.
    Open Calendar (or iCal) and test to see if the issue is resolved.
    Restart your computer. This may sound simple, but it reinitializes your network and application settings and can frequently resolve issues.
    If the issue persists, try all remaining steps in the article below. 
    iCloud: Troubleshooting iCloud Calendar
    http://support.apple.com/kb/TS3999
    Regards,
    Jason H. 

  • Report Footer overlapping Last four records in the report body.

    <p>Hi All,</p><p>In all of my reports have more than 20 Pages. All of my reports are Webintellegence format. these reports we deployed in Java Appplication. Java Application is in Tiles Frame Work Architecture. </p><p><strong>Here Problem is all of my reports have report footer. that footer is Overlapping Last Four rows in the Report Body. in Infoview it&#39;s looks fine. in Application only this problem we are facing. </strong></p><p>In Application just we are displaying HTML Content. This HTML content Contains everything. Report  Header and Body and Footer</p><p>We are not able to understand this. Please tell me where is the problem this is in Businessobjects problem or Application Problem.</p><p>If any one facing same problem please let me know the solution.</p><p>Thanks & Regards</p><p>Vallabhaneni </p>

    Every page should leave last two line of the body to print other content (some summary)

Maybe you are looking for

  • Applet not getting loaded in Windows Vista's Mozilla Browser

    Hi, When I open the URL http://www.operamini.com/demo/ , the applet in that site gets loaded from windows XP and linux, but not from windows vista, for the same firefox version. When I refer the Java console I get the message lissted below. c:   clea

  • Sequence of execution

    Hello to every body I need to know about sequence of execution in a select command. I have a sql command that use a function.some thing like: select id, function(item) from tbl where conditions... I want to know that if my function on item execute be

  • Can u just tell me how to use leap motion while using lappy & other apps also

    I hv bought HP envy leap motion few months back and i m not able to understand leap motion features.I've seen many videos about the features but i m not able to do it.Plzz help me

  • PARAMETERS Default Path

    HI all; am working with ALV Reports . These reports will be displayed data in ALV Format and  as well it will Transfered the ALV displayed data into xml files. for given location in application server. PARAMETERS zfname TYPE AUTHB-FILENAME DEFAULT ''

  • Windows 8.1 issues

    We have been using WSUS for about a year.  Our version is 3.2.7600.226.  Everything has been working fine until we added some Windows 8.1 clients.  They will download the updates from WSUS, but don't appear to automatically install them.  I've checke