How to get the MAX,MIN from the below table...

Hi,
Database is SQL2012 R2 Express and I have a table and would like to dig out the MAX,MIN value of a specifiied date (e.g 2014-11-03)
Thanks

Nope... It still output more than 1 value on the same date...
DL-01-BAT 13.00753 13.00753 10/10/2014
DL-01-BAT 13.01342 13.01342 10/10/2014
DL-01-BAT 13.02706 13.02706 10/10/2014
DL-01-BAT 13.03485 13.03485 10/10/2014
Raw data is
DL-01-BAT 13.00753 13.00753 10/10/2014 20:00
DL-01-BAT 13.01342 13.01342 10/10/2014 21:00
DL-01-BAT 13.02706 13.02706 10/10/2014 22:00
DL-01-BAT 13.03485 13.03485 10/10/2014 23:00
You mean after applying my suggestion?
I dont think so
See illustration below
declare @t table
Item VARCHAR(10), Reading VarChar(50),DateTimeReading DATETIME)
INSERT @t
VALUES
('DL-01-BAT', 13.00753,'10/10/2014 20:00'),
('DL-01-BAT', 13.01342,'10/10/2014 21:00'),
('DL-01-BAT', 13.02706,'10/10/2014 22:00'),
('DL-01-BAT', 13.03485,'10/10/2014 23:00')
DECLARE @Date datetime = '20141010'
SELECT Item,
MAX(Reading) AS [Max],
MIN(Reading) AS [Min],
DATEADD(dd,DATEDIFF(dd,0,DateTimeReading),0) AS [Date]
FROM @t
WHERE DateTimeReading >= @Date
AND DateTimeReading < DATEADD(dd,1,@Date)
GROUP BY Item, DATEADD(dd,DATEDIFF(dd,0,DateTimeReading),0)
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to get first 10 records from the database using JSP

    i want ot get first 10 records from the database and then after clicking the next button in the page,it must show the next precceding 10 records from the database.i am getting the first 10 records .but how to post to the same page to get another preceeding 10 record.

    Search the forums - this has been asked a lot. I usually recommend experimenting with tops and order bys until you're satisfied.
    Kind regards,
      Levi

  • How to get ther servlet name from the Httprequest / servletContext

    Hi,
    How can I get the servlet name from the Http Request / Servlet conext?
    Arthik

    I have a requirement to call the business logic either in local server / external server.
    Local / External server
    The original / main request is made to the server from the client and from the server if the main request requires some resource (second request from server side) available in the external server then I need to make a URL connection. If the requested resource is the local resource then I need to by-pass the HTTP call. So I need to verify the server name , port with the originally requested server.Then I need to check if the request servelt is available in local or not.
    Can you please help me.

  • ADF BC - How to get validation picked up from the database.

    Is there a way the ADF BC can be created so it contains the check constraints from the database?
    I assume if it did, it would pre-fill the "validation" branch in the Entity Object Editor.

    Frank,
    Thank you very much for your reply. I've set "valuePassThrough" property of the dropdownlist to true. In the valueChangeListener, my code looks like this.
    public void TD_valueChangeListener(ValueChangeEvent valueChangeEvent) {
    System.out.println("+++++++++");
    System.out.println("TD_valueChangeListener");
    Number n = null;
    BindingContainer bc = this.getBindings();
    if(bc != null){
    System.out.println("bc is not null");
    //get the selected TD
    FacesCtrlListBinding TdIter = (FacesCtrlListBinding)bc.get("LandLegalView1Td");
    if(TdIter != null){ 
    System.out.println("TdIter is not null");
    if(valueChangeEvent.getNewValue() != null)
    try{n = new Number(valueChangeEvent.getNewValue());}
    catch(Exception e){
    e.getMessage();
    System.out.println("selected TD index="+n);
    //Object td = TdIter.getAttributeFromRow(n.intValue(), "Td");
    Object td = TdIter.getAttribute(n.intValue());
    System.out.println("real value of td=" + td);
    }else{
    System.out.println("TD is null");
    }else{
    System.out.println("TdIter is null");
    My question here is: I tried two ways of getting the real value of the new selected value. One is "Object td = TdIter.getAttributeFromRow(n.intValue(), "Td");". The other is "Object td = TdIter.getAttribute(n.intValue());". None of them give me the new selected value but the old value. Did I do anything wrong?
    Regards,
    Annie

  • How to get Original Message ID from the MDN of Acknowledgment?

    Hi,
    Here is the usecase...
    Host Trading Partner: ABCHost (Host)
    Trading Partner: XYZPartner
    Transport Protocol: HTTP1.1
    Exchange Protocol: AS2
    Business Protocol: Custom Document over Internet
    There are 1000s of messages sent via B2B to the Trading partner and the Acknowledgement is received. Now that the Trading Partner system receives a lot of messages per day, they are asking us to give them the MDN Ids from the Acknowledgment they sent in order to find the transaction.
    Is there a way to generate a report to do that using the Timestamp, Business Action, Sending/Host Trading Partner, AS2 Identifiers etc.?
    If not thru' the B2B Console, is there a way to write a query to run on the backend to generate the report?
    Thanks
    Bala

    Hi Bala,
    You can see the details of MDN in the B2B repository in the view "b2b_instancemessage" or in the table "tip_businessmessage_rt".
    You can refer InstanceMessageUtil (http://download.oracle.com/docs/cd/B14099_19/integrate.1012/b19324/oracle/tip/adapter/b2b/utility/InstanceMessageUtil.html).
    Rgds,
    Nitesh Jain
    [email protected]

  • How to get login crenditials(Result) from the MBO in a js file

    Hi Experts,
        I got a table from oracle db, and i have deployed it and MBO is generated.
    That table contains the login credentials which i am giving in the login page.
          I have created a login page with user id and password when i am trying to login by using the credentials which i have registered earlier the credentials are being checked in the table and it should return me yes or no if yes i have to move to next screen if no i should display some alert . My problem is that i am not knowing how to get that verified credentials and display them in my code. I am writing this line of code in java script and i am unable to know, how to handle the data after being checked from the MBO .. please help me out of this ..

    Hi Lokesh,
    You can write an object query for checking the credentials details.
    Right click mbo>Attributes>Object query>Add
    Add 2 parameters, give some name like usernameParam and passwordParam
    Map these parameters to respective fields like username and password(from MBO)
    Generate object query
         e.g. select x.username, y.password from ABC where x.username=:usernameParam and      y.password=:passwordParam
    select Return type"as single object""
    (assuming username and password are the parameters defined in the mbo ABC.)
    redeploy mbo
    call this object query to Login button and do all required mappings
    For verification, if details are/not available in backend
    You have to write some piece of code in customBeforeNavigateForward
    e.g.
    hwc.customBeforeNavigateForward = function(screenKey, destScreenKey) {
    if(destScreenKey="Employee" && screenKey=="Start"){
    //Here Employee is the MBO name
    alert("test");
    var message = getCurrentMessageValueCollection();
    alert("test1");
    var itemList = message.getData("Employee");
    alert("test2");
    var items = itemList.getValue();
    var noOfItems = items.length;
    alert("noOfItems="+noOfItems);
    if(noOfItems==0){
    alert("Invalid input");
    return false;
    Rgrds,
    Jitendra

  • How to get file input stream from the client machine by JSF Fileupload API?

    Dear Friends,
    How to get the file input stream from the client machine by JSF HtmlFileupload or fileupload API. At present, if i execute the file upload code in the client machine, it is able to get the local path of the file and looking for the file in server machine. So i am getting FileNotFoundException.
    E.g., If a file is located at client machine at following location means "C:\Test\Test.txt",
    uploadClass.getFileuploadComponent().getFilename().toString() returns "C:\Test\Test.txt". But it is looking for that file in server and throwing FileNotFoundException.
    Please post your replies soon.
    Thanks,
    JP

    Depends on which version of JSF you're using. If JSF 1.2, I wouldn't even bother trying to hack this into JSF itself unless you can use something like Seam 2 or richfaces.
    http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_fileUpload.html
    http://docs.jboss.org/seam/2.2.1.CR3/reference/en-US/html/controls.html#d0e29259 (look for s:fileUpload)
    But if I were you, a simple non-jsf form with a servlet works best for taking file uploads.
    As for JSF 2.0, there are other ways of getting it done.
    http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html

  • How to get Fennec full screen from the android project's source code?

    Hi,
    First and foremost, I'm sure this was not the proper category to post that question but I couldn't really figure out a better one. Hopefully you'll forward it to a better place.
    We would like to take the advantages of Fennec with out HTML5 framework by wrapping it into a somewhat WebView like you can do on Android. The native implementation of the webview on Android turns out to be very disappointing so far whereas Fennec runs seamlessly.
    Could you recommend us any tips to do that properly from the Fennec's Android app project?
    Basically we just want to be able to call sort of a new FennecWebView() class instance in our code (instead of the formerly new WebView() ) that will run full-screen and won't call any further things such as, bookmark manager, setting. We just want to scale this down to the very strict minimum in order to run our Canvas framework in a native app thanks to the Fennec's engine.
    Thank you very much!
    BR,
    Armand

    I've seen some interest in this from others. It was suggested that they build a web app manifest.
    https://developer.mozilla.org/en-US/docs/Apps/Getting_Started
    https://hacks.mozilla.org/2013/01/join-us-for-firefox-os-app-days/

  • Help to find the max, min and the averages wages

    ok i did sum programming i got half of my program to work but i need help with the other half the program is suppose to find the highest and lowest wages and also give the average wages. here is my code
    import java.util.*;
        public class WorkerwagesQueues
          static Scanner console = new Scanner(System.in);
           public static void main (String[] args)
             Queue<String> nameQ = new LinkedList<String>();
             Queue<String> nameQ2 = new LinkedList<String>();
             Queue<Double> num = new LinkedList<Double>();
             int searchCnt = 0;
             int max, min;
             String toSearch, var;
             System.out.println("Welcome, how are you Doing today\n");
             System.out.println("Please enter the five workers names\n");
             for (int i = 0; i < 5; i++)
                nameQ.offer(console.next());
             System.out.println("Please enter the five workers salaries\n");
             for (int i = 0; i < 5; i++)
                num.offer(console.nextDouble());
            // starting right here is my problem
            /*min = num.next(0);
             max = num.get(0);
             for (int i = 0; i < num.size(); i++)
                System.out.println(num.get(i));
                if (i > 0)
                   if (min > num.get(i))
                      min = num.get(i);
                   if (max < num.get(i))
                      max = num.get(i);
             System.out.println("\nthe Lowest wage is " + num );
             System.out.println("\nthe Largest wage is " + num );
             System.out.println("please enter a name to serach the queue:");
             toSearch = console.next();      
             while (nameQ.size() > 0)
                var = nameQ.remove();
                if (var.equals(toSearch))
                {searchCnt++;}
                else
                {nameQ2.offer(var);}               
             System.out.println("This queue contains " + toSearch + " " + searchCnt + " time(s).");
             System.out.println("The second queue is:");
       }

    ok sorry if i am annoying you guys but i really want to get this working
    this is the part i am having problems with. I am trying to find the max and min of the wages the user input and i am not usre how to do it. my question is how do i do that?
    // starting right here is my problem
            /*min = num.next(0);
             max = num.get(0);
             for (int i = 0; i < num.size(); i++)
                System.out.println(num.get(i));
                if (i > 0)
                   if (min > num.get(i))
                      min = num.get(i);
                   if (max < num.get(i))
                      max = num.get(i);
             System.out.println("\nthe Lowest wage is " + num );
             System.out.println("\nthe Largest wage is " + num );
         

  • How to get PO CHANGE HISTORY from back end tables?

    Hi All,
    I need to get the PO Change history from the back end reason being users want to see not only the change made but who made the changes on those PO's. The PO change history.html doesnot give the information of the user who made changes to the PO. Can any one provide me the query involved in this html page. I can add the updated_by column to that. I built a query already but it is not giving me the field altered on the PO Line.
    I learnt that we can get the information from the archive tables but my question is how to know which field has been changed from the original PO to the revised PO. I am unable to figure out if that revision is for Unit Price change or amount change or Bill to change etc. i.e., as it shows in PO change History html page I need to see which field is altered on a particular PO. Is that possible?
    Thanks for your help!
    Prathima
    Message was edited by:
    Prathima

    Hi Anil,
    Turning Audit on PO_LINES_ALL helped to track the changes. I have a problem though.
    In the sense - Below is the query I created to track changes on Unit Price of a Po Line.
    SELECT
    poh.segment1 po_num
    ,pol.line_num po_line_num
    ,pola.unit_price price_changed_from
    ,pol.unit_price price_changed_to
    ,fnd1.description created_by
    ,fnd.description last_updated_by
    ,fnd2.description previously_updated_by
    --,decode(pola.audit_transaction_type,'U','UPDATE','I','INSERT') audit_transaction_type
    ,pol.last_update_date
    FROM po.po_lines_all_a pola,po.po_lines_all pol,apps.fnd_user fnd,apps.fnd_user fnd1,po.po_headers_all poh,apps.fnd_user fnd2
    WHERE pola.po_line_id = pol.po_line_id
    AND pola.audit_transaction_type = 'U'
    and poh.po_header_id = pol.po_header_id
    AND fnd.user_name = pola.audit_user_name
    and pola.unit_price is not null
    and fnd1.user_id = pol.created_by
    and fnd2.user_id(+) = pola.LAST_UPDATED_BY
    Now the problem is
    When I update a line twice. intially I changed the unitprice value of line 4 from .72 to 0.8 and later I changed it back to 0.8 to 0.72. Intial Changed to 0.72 shuld be 0.8 but it changed to 0.72 as it is pulling from po_lines_all table. How can you capture that changed to???
    po_num Line Changed from Changed to
    26603     4     0.72000      0.72000
    26603     4     0.80000     0.72000
    Please help.
    Thanks,
    Prathima

  • How to get your $200 back from the price drop.

    Many of you likely paid with a credit card and many of the credit card companies have a price protection policy. I know american express and some mastercards do. Basically if you buy a product and the price goes down within 60 or 90 days depending on the credit card company, you get back the price difference. I know for mastercard they will refund up to $250. Try that out.

    I just got off the phone with my credit card company (ATT Universal) and they have confirmed that they do indeed honor "retail purchase protection." If you have purchased an item and the merchant drops the price within 60 days, then you can obtain a refund of up to $250.
    To all of us jilted Apple-lovers, I would suggest this course of action to resolve if possible. It's one thing to have a lone customer whining to an assistant manager of an Apple store, it's another thing to have a room full of lawyers for credit card companies in an Apple board room asking Apple how it plans to resolve the large numbers of refunds that the credit card companies were forced to pay out.
    Good luck, all!

  • How to get rid of stuff from the hard drive

    Our family iMac, with a 500GB hard drive, has only 5 GB of space left. Is there a quick, efficient way to get rid of duplicate stuff, large files, unused programs that just take up space?

    take a look @ [WhatSize|http://www.id-design.com/software/whatsize>.
    also, here's some reads to peruse:
    Your Mac needs adequate hard drive space to operate normally. How full can a drive be before it's too full? There is no hard and fast rule that says “X” amount or “%” of free drive space is needed. A low amount of RAM requires more drive space for Virtual Memory’s swap files.
    Problems from insufficient RAM and free hard disk space are discussed in this link
    http://www.thexlab.com/faqs/lackofram.html
    Here’s some general guidelines for minimum hard drive free space:
    1. As a general rule, your available space should be 5GB as an absolute minimum as it generally requires that much free space to perform an Archive and Install of Mac OS X and still preserve some free space for VM swap files.
    2. Some say that your hard drive should have at least 5% of it's capacity available for use. Still others say 10% to 15%. If you routinely process complex graphics and videos, even more space is required.
    Look at these links about freeing up more space.
    Where did my disk space go?
    _*http://www.macfixitforums.com/showflat.php?Cat=&Board=Forum38&Number=770243*_
    Download & use WhatSize described in this link or Disk Inventory X @ _*http://www.derlien.com/*_
    Freeing space on your Mac OS X startup disk
    _*http://www.thexlab.com/faqs/freeingspace.html*_
    Amazing Disappearing Drive Space
    _*http://www.pinkmutant.com/articles/TigerMisc.html*_
    Increase HD Free Space
    _*http://macosx.com/forums/howto-faqs/275191-how-easily-increase-hd-free-space-lap top.html*_
    How to free up my disk space
    http://www.macmaps.com/diskfull.html
    JGG

  • How to retrieve the max value from a cursor in procedure

    Hi,
    In a procedure, I defined a cursor:
    cursor c_emp is select empno, ename, salary from emp where ename like 'J%';
    but in the body part, I need to retrieve the max(salary) from the cursor.
    could you please tell me how I can get the max value from the cursor in the procedure.
    Thanks,
    Paul

    Here is one sample but you should just get the max directly. Using bulk processing should be a last resort.
    DECLARE
      CURSOR c1 IS (SELECT * FROM emp where sal is not null);
      TYPE typ_tbl IS TABLE OF c1%rowtype;
      v typ_tbl;
      max_sal number;
    BEGIN
      OPEN c1;
      max_sal := -9999999999999;
      LOOP                                                 --Loop added
        FETCH c1 BULK COLLECT INTO v LIMIT 3; -- process 3 records at a time
            -- process the records
           DBMS_OUTPUT.PUT_LINE('Processing ' || v.COUNT || ' records.');
            FOR i IN v.first..v.last LOOP
                 if v(i).sal > max_sal then
                   max_sal := v(i).sal;
                 end if;
                DBMS_OUTPUT.PUT_LINE(v(i).empno);
            END LOOP; 
        EXIT WHEN c1%NOTFOUND;
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('Max salary was: ' || max_sal);
    END;
    Processing 3 records.
    7369
    7499
    7521
    Processing 3 records.
    7566
    7654
    7698
    Processing 3 records.
    7782
    7788
    7839
    Processing 3 records.
    7844
    7876
    7900
    Processing 2 records.
    7902
    7934
    Max salary was: 5000

  • Getting a document file from the transcribed audio file

    I would like to know how to get a "document" file from the transcribed files created by Soundbooth. The files created by SB have 'xml' or 'xmp' extensions and I do not know what to do with these files or how to "read" them.
    I am on a macbook pro MAC OS 10.5.5. I have latest versions of Word, and Final Cut Pro.
    Any help would be appreciated. This is my first foray into the world of Adobe products.
    Thanks,
    Eric

    The Transcript XML files conform to the XML Standards, and are a "marked up" text document containing several pieces of information. You can open the file in TextEdit (on Mac) or Notepad (on Windows) and you should be able to see what sorts of metadata is saved for each word in the transcription. Each transcribed word is stored in a data block, along with its timestamp, the duration of the spoken word, and some other metadata. This information is invaluable when importing the file into other applications or databases.
    Neither Soundbooth nor Premiere Pro support exporting the transcript without the additional metadata or XML tags right now, but since it's a basic text file, it should be a very simple chore for a script to parse that file and write out each transcribed word to a new file.
    Durin

  • To retrieve the Maximum Date from the record

    Hi All,
    I am using the bleow query to retrieve the max date from the record list:
    select w.wr_no,w.customer_id,w.place_id, w.entry_Date, max(app.appointment_date) as appointment_date
    from work_request w , wr_appointment app
    where w.wr_no=app.wr_no
    and w.customer_id = '020167001'
    and w.place_id = '1151667'
    group by w.wr_no, w.customer_id,w.place_id, w.entry_Date;
    However i am getting the as many as three rows even after using the max function. The max date comes as the last record out the three rows retrieved.
    Thanks,
    Mark

    Mark Andrew wrote:
    And for Sven for the above customer id and place id, i receive the below result:
    WR_NO CUSTOMER_ID PLACE_ID ENTRY_DATE APPOINTMENT_DATE
    1306782233 020167001 1151667 26/07/2010 29/07/2010
    1387090103 020167001 1151667 26/02/2010 16/03/2010
    1393896673 020167001 1151667 23/01/2011 25/01/2011
    After using the rank function i will be receiving:
    WR_NO CUSTOMER_ID PLACE_ID ENTRY_DATE APPOINTMENT_DATE RK
    1393896673 020167001 1151667 23/01/2011 25/01/2011 1Now I get it.
    In fact you want to group only on the customer (and place_id?) and get all the information from the line with the last appointment date.
    Analytic functions such as RANK or ROW_NUMBER are good for this.
    The select can look like this.
    select * from (
       select w.wr_no,w.customer_id,w.place_id, w.entry_Date, app.appointment_date,
             row_number() over (partition by w.customer_id, w.place_id order by  app.appointment_date desc,  w.wr_no desc) rn
       from work_request w , wr_appointment app
      where w.wr_no=app.wr_no
      --and w.customer_id = '020167001'
      --and w.place_id = '1151667'
    where rn = 1
    ;In fact I think you can do the same operation in EXCEL directly.
    FIrst you need to sort the data by customer (asc), place (asc) and appointment date (desc).
    Then add a column in excel that give you the line where you have a new customer id.
    Assuming this new column is column H and the customerid is in column A then the function in Cell H2 would look like this.
    A function like ("=A2=A1"). Copy this formular to all the other H cells.
    Then add a auto filter on it and only select all the rows where the result is FALSE.
    Same logic as in SQL, but done in Excel.

Maybe you are looking for

  • Pricing condition in Info record.

    Dear All, I am facing a strange problem. We have define one condition type ZBAS-Basic Duty in %. In Developement client 300 it is appearing in drop down for maintaing condituion is info records manually & also in PO. In testing client it is not appea

  • Illustrator images have white background

    Why when I place AI images into my ID spreads do the AI images print with a white background? Bitmap or Photoshop images print with transparent backgrounds but AI images always have a white background. Did I forget something in Illustrator?

  • Creating Password Protected MS WORD File

    Hi, i reported a program which creating password protected ms excel file using OLE2 objects in local harddisk of computer. can i report same program with ms word file? Can somebody help me pls? Thanks.

  • IPAD NIGHTMARES: NYTimes app won't load anymore... and more!!

    That's the thing: a week short I bought my iPad in Spain, I'm back to Brazil and bad surprises started happening: 1. My NYTimes app does not open anymore (the screen shows for minutes that it's "loading". Forever); 2. My Mail app (yes, the Apple one)

  • Problems with SVG line charts based on PL/SQL returning SQL

    Dear all - I wonder if anyone can tell me whether this problem is likely to be fixed at some point? It relates to the fact that you can't get more than one series on a chart where the SQL is returned from PL/SQL. It is a huge issue for us when trying