Round And Trunc

What is the difference between ROUND and TRUNC functions in SQL

The docs are your friends.
Round Number
Round Date
Trun Number
Trunc Date
Cheers
Sarma.

Similar Messages

  • Round and Trunc with dates

    Can i get the examples for Round and Trunc with dates?

    Hi Rahul,
    Check out this workout by Tom Kyte on TRUNC and ROUND -
    http://www.oracle.com/technetwork/issue-archive/2012/12-sep/o52sql-1735910.html
    Dont skip even a single line of it. Really useful.
    My little workout :
    Ranit>> select
      2  round(123.444) r1,
      3  round(123.999) r2,
      4  trunc(123.444) t1,
      5  trunc(123.999) t2
      6  from
      7  dual;
            R1         R2         T1         T2                                                                                                                                                                                
           123        124        123        123                                                                                                                                                                                
    Ranit>> select
      2  round(123.444,2) r1,
      3  round(123.999,2) r2,
      4  trunc(123.444,2) t1,
      5  trunc(123.999,2) t2
      6  from dual;
            R1         R2         T1         T2                                                                                                                                                                                
        123.44        124     123.44     123.99                                                                                                                                                                                
    Ranit>> select
      2  round(123.1234,2) r1, -- "Rounds upto 2 Decimal places"
      3  round(123.1266,2) r2, -- "Rounds upto 2 Decimal places"
      4  trunc(123.1234,2) t1, -- "Keeps only 2 decimal places and Truncates the rest"
      5  trunc(123.1266,2) t2  -- "Keeps only 2 decimal places and Truncates the rest"
      6  from
      7  dual;
            R1         R2         T1         T2                                                                                                                                                                                
        123.12     123.13     123.12     123.12                                                                                                                                                                                
    --"Note the difference in R2 andT2 values : In R2 there's a data round-off done but in T2 it is simple cut-off of extra decimal part"HTH
    Edited by: ranit B on Jan 26, 2013 7:24 PM

  • ROUND and TRUNC function

    Guys,
    About the query below, how is the output and how SQL treats that?
    SELECT TRUNC(ROUND(156,00,-1),-1)
    FROM DUAL
    Thank you!

    Don't be afraid of breaking Oracle by actually trying things.
    Break it into pieces and look at each piece one at a time.
    Remove the TRUNC operation and see what you get. Do you understand why you get that result? If not, post it and we can help explain it.
    But you need to make the effort yourself.
    See the SQL Language doc. It has an example just like yours.
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions142.htm
    >
    ROUND returns n rounded to integer places to the right of the decimal point. If you omit integer, then n is rounded to zero places. If integer is negative, then n is rounded off to the left of the decimal point.
    The following example rounds a number one digit to the left of the decimal point:
    SELECT ROUND(15.193,-1) "Round" FROM DUAL;    Round  ----------  20 
    >
    Which means your number, 156,00, will get rounded one digit to the left of the decimal point. So 156 gets rounded to 160.00 since the '6' is equal to or larger than '5' it gets rounded up.
    That leaves a result of 160.00. The TRUNC operation does something similar excepts instead of rounding one place left it truncates. But since one place left already has a '0' there is nothing for TRUNC to do so you still have 160.00

  • My ipod 60gb classic is showing as fully charged until I connect it to my pc when it comes up with the error message, 'please wait very low battery' and the little wheel goes round and nothing happens, can anyone explain why this is and what i can do?

    My ipod 60gb classic is showing as fully charged until I connect it to my pc when it comes up with the error message, 'please wait very low battery' and the little wheel goes round and nothing happens, can anyone explain why this is and what i can do?

    I have worked my way through the assistant and nothing works. I have tried connecting in disc mode but although the screen on the ipod is showing that the device is charged and that it is in disc mode as soon as I connect it to the computer it comes up with the error message 'please wait very low battery' and stays like that until I disconnect when it appears to be OK again. I have tried on both pc and mac.
    BTW the ipod is an ipod video not classic if that makes any difference.
    Thanks

  • So my Ipod touch hasn't been connecting to computer, or charging for a week or two until i turn it off completely and now i try to reset all content and setting, the circle goes round and round for like hrs(24) and it still does not complete the reset

    so my Ipod touch hasn't been connecting to computer, nor charging for a week or two until i turn it off completely and now i try to reset all content and setting,(thinking it may connect to the computer and itunes and also charge) but the circle goes round and round for like hrs(24) and it still does not complete the reset.
    pls pls pls pls help .
    i have tried alot of solutions, but non of them have worked.

    Have you tried walking it into the nearest Apple Store and asking for assistance there...?
    I'm guessing you don't have Apple Care on it.

  • Sql query usig round and decode together

    can i get one sql quer for returning whole number using round and decode function
    eg:
    the value 47
    if value=47
    then
    the query should return 50
    if the value =44
    then
    the quer should return 40
    pls give me sql query for above example using round and decode function
    Edited by: user11368167 on Jul 9, 2009 3:35 AM

    A wild guess. If you want the ROUND Function to work only when your column value is 44 or 47 then you could use something like:
    SQL> WITH test_tab AS
      2       (SELECT 44 col_1
      3          FROM DUAL
      4        UNION ALL
      5        SELECT 15 col_1
      6          FROM DUAL
      7        UNION ALL
      8        SELECT 47 col_1
      9          FROM DUAL
    10        UNION ALL
    11        SELECT 45 col_1
    12          FROM DUAL)
    13          -- end of test data
    14  SELECT col_1,
    15         DECODE (col_1,
    16                 44, ROUND (col_1, -1),
    17                 47, ROUND (col_1, -1),
    18                 col_1
    19                ) rounded_value
    20    FROM test_tab
    21  /
         COL_1 ROUNDED_VALUE
            44            40
            15            15
            47            50
            45            45
    4 rows selected.
    SQL> CASE Statement can be used as well instead of DECODE.
    Good Luck,
    Regards,
    Jo

  • I'm trying to update my apps using the creative cloud desktop app. I can't see any apps in the app tab, the wheel just spins round and round and nothing happens. Has anyone got any ideas? I've tried uninstalling the desktop app and reinstalling but it sti

    Hi
    I'm trying to update my apps using the creative cloud desktop app. I can't see any apps in the app tab, the wheel just spins round and round and nothing happens. Has anyone got any ideas? I've tried uninstalling the desktop app and reinstalling but it still has the same problem.
    Cheers
    Rachel

    Hi Rachel,
    You can follow the article: App doesn't open | Progress wheel spins continually to get your issue fixed.
    Let us know if the issue still persists or not.
    Regards,
    Ratandeep Arora

  • HT1414 Itunes just goes round and round when i tap on recent purchases and cant get at recent songs purchased on my non apple laptop. I don't connect my iPad to a computer. How do I tackle this?

    When I open iTunes on my iPad and tap on purchased for music, the timer just goes round and round and won't find my purchased tunes and I can't therefore download any new items I have bought. Any suggestions on how to reload the software?

    Make sure you have a good wifi connection.
    Make Sure iOS is updated to the latest version
    Reboot the device by pressing and holding down the home and sleep/wake buttons (power) at the same time until the apple logo appears on the screen, then let go.
    If that doesn't work then reset the device by going to settings/general/reset/reset all settings

  • Went to use my ipad tonight and the screen is blank except for a little circle going round and round and I ccant switch the device off

    Went to use my ipad tonight and the screen is black with just a small circle in the middle going round and round.  I thought i would switch it off but it wont let me do that either.  HELP

    Try a soft-reset : press and hold both the sleep and home buttons for about 10 to 15 seconds, after which the Apple logo should appear and it should reboot - you won't lose any content, it's the iPad equivalent of a reboot.

  • How do i cancel after the circles of hell go round and round?

    I have been in the circles of hell trying to cancel my subscription which my credit card, i was surprised to learn, had been charged for- only to find it is already cancelled! See below
    Adobe ExportPDF, Annual
    Cancelled: Effective February 2, 2016
    Restart
    But I have just been billed for it anyway. And probably be billed for it in another year - 2016. And then it will probably "automatically" (see fine print) restart.and so on till i am very very old. interesting to see on other posts that cancelling the credit card does not help which seems odd but then again after two hours of wandering round and round the site (love the hilarity of the non-functioning chat icon - much hilarity every Christmas in the accounting department.) I'm not surprised. It is clear that adobe has one of the most difficult "unsubscribes" online. Despite the professionals hunting them down and killing them, there are still websites devoted to the topic of why can't I unsubscribe and why is this so hard and surely this is illegal. Adobe clearly makes most of its money out of the unsubscribe because the two products I bought didn't work anyway. Fair enough, should have known, but remind me to employ a lawyer in future before even opening an adobe document.

    Hi there,
    Sorry for the frustrating experience, looking at the account I could see the billing has been stopped for the subscription and you will continue to have the access to software till 2016.
    Please update this thread if you would like to cancel the subscription and get refund.
    ^Ani

  • Can't access my files, the circle thing keeps going round and round

    I can't access my files, the little cursor thing keeps going round and round, is there a way to by pass that or is my powerbook going dead

    What version of OS X are you running?
    Useful article here on the causes of the Spinning Beach Ball and how to troubleshoot it:
    http://www.computerworld.com/s/article/9177479/Troubleshoot_the_spinning_beach_b all?taxonomyId=89&pageNumber=1
    and also this:
    http://www.thexlab.com/faqs/sbbod.html

  • Hey! I don't know if my MacBook Air is frozen, but the screen is gray with the apple logo and an icon below turning round and round as if it's opening, but has been like that for a few days. I've switched it off and then on again several times, still the

    Hey
    I don't know if my mac book air is frozen, but the screen is gray with the apple logo in the middle of the gray screen, with the 'booting' icon turning round and round. I have switched it off fron both the power and power button on the computer, it goes off, when I put it on, same screen comes on again. Help Please!

    Take each of these steps that you haven't already tried. Stop when the problem is resolved.
    Step 1
    The first step in dealing with a boot failure is to secure your data. If you want to preserve the contents of the startup drive, and you don't already have at least one current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about the data that has changed since your last backup, you can skip this step.   
    There are several ways to back up a Mac that is unable to boot. You need an external hard drive to hold the backup data.
         a. Boot into the Recovery partition, or from a local Time Machine backup volume (option key at startup.) When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    b. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    c. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.
    Step 2
    Sometimes a boot failure can be resolved by resetting the NVRAM.
    Step 3
    If you use a wireless keyboard, trackpad, or mouse, replace or recharge the batteries. The battery level shown in the Bluetooth menu item may not be accurate.
    Step 4
    If there's a built-in optical drive, a disc may be stuck in it. Follow these instructions to eject it.
    Step 5
    Press and hold the power button until the power shuts off. Disconnect all wired peripherals except those needed to boot, and remove all aftermarket expansion cards. Use a different keyboard and/or mouse, if those devices are wired. If you can boot now, one of the devices you disconnected, or a combination of them, is causing the problem. Finding out which one is a process of elimination.
    If you've booted from an external storage device, make sure that your internal boot volume is selected in the Startup Disk pane of System Preferences.
    Step 6
    Boot in safe mode. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Post for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    When you boot in safe mode, it's normal to see a dark gray progress bar on a light gray background. If the progress bar gets stuck for more than a few minutes, or if the system shuts down automatically while the progress bar is displayed, your boot volume is corrupt and the drive is probably malfunctioning. In that case, go to Step 6.
    If you can boot and log in now, empty the Trash, and then open the Finder Info window on your boot volume ("Macintosh HD," unless you gave it a different name.) Check that you have at least 9 GB of available space, as shown in the window. If you don't, copy as many files as necessary to another volume (not another folder on the same volume) and delete the originals. Deletion isn't complete until you empty the Trash again. Do this until the available space is more than 9 GB. Then reboot as usual (i.e., not in safe mode.)
    If the boot process hangs again, the problem is likely caused by a third-party system modification that you installed. Post for further instructions.
    Step 7
    Launch Disk Utility in Recovery mode (see Step 1.) Select your startup volume, then run Repair Disk. If any problems are found, repeat until clear. If Disk Utility reports that the volume can't be repaired, the drive has malfunctioned and should be replaced. You might choose to tolerate one such malfunction in the life of the drive. In that case, erase the volume and restore from a backup. If the same thing ever happens again, replace the drive immediately.
    This is one of the rare situations in which you should also run Repair Permissions, ignoring the false warnings it may produce. Look for the line "Permissions repair complete" at the end of the output. Then reboot as usual.
    Step 8
    Reinstall the OS. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade.
    Step 9
    Repeat Step 6, but this time erase the boot volume in Disk Utility before installing. The system should automatically reboot into the Setup Assistant. Follow the prompts to transfer your data from a Time Machine or other backup.
    Step 10
    This step applies only to older Macs (not current models) that have a logic-board ("PRAM") battery. Both desktop and portable Macs used to have such a battery. The logic-board battery, if there is one, is separate from the main battery of a portable. A dead logic-board battery can cause a boot failure. Typically the failure will be preceded by loss of the settings for the startup disk and system clock. See the user manual for replacement instructions. You may have to take the machine to a service provider to have the battery replaced.
    Step 11
    If you get this far, you're probably dealing with a hardware fault. Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.

  • Are Truncate and Trunc SQL ISO ANSI compliance ?

    Somebody has idea of
    which of the statements TRUNCATE and TRUNC are SQL ISO ANSI compliance ?
    is Truncate a function or a statement ?
    Thanks
    Nelson

    perhaps this answer has the potential to add some confusing, but maybe it shows a little problem with ANSI compliance:
    For Oracle a TRUNCATE TABLE is a DDL operation that includes an implicit commit preventing a rollback:
    -- Oracle 11.2.0.1
    SQL> create table t(a number);
    Tabelle wurde erstellt.
    SQL> insert into t(a) values(1);
    1 Zeile wurde erstellt.
    SQL> commit;
    Transaktion mit COMMIT abgeschlossen.
    SQL> truncate table t;
    Tabelle mit TRUNCATE geleert.
    SQL> rollback;
    Transaktion mit ROLLBACK rückgängig gemacht.
    SQL> select * from t;
    Es wurden keine Zeilen ausgewählt
    Sorry about the german sqlplus feedback - but I think the result is clear: the table is empty after the truncate and the data is gone.
    But for MS SQL Server a TRUNCATE can be rolled back:
    -- SQL Server 2008
    drop table t;
    create table t(a int);
    insert into t(a) values(1);
    begin transaction
    truncate table t;
    rollback;
    select * from t;
      a
      1
    Microsoft also defines TRUNCATE as DDL - http://msdn.microsoft.com/en-us/library/ff848799.aspx - but the behavior is quite different. So ANSI compliance does not mean that much (I have absolutly no idea which of the two solutions is more ANSI compliant in this case).
    Regards
    Martin

  • Photoshop crashes when I change the roundness and rotation of brushes

    Photoshop SC4 64bit Vista.
    It appears to be very predictable crash that always happens within about 1 to 10 minutes every time after using brushes with different roundness and rotation.
    I usually paint with 100% round brushes with Shape and Other Dynamics checked and set to pen pressure and Photoshop never crashes. However recently I started to change the roundness and rotation of the brushes and Photoshop started to crash when I do that.
    So far the crashing occurs during painting when the brush palette is open and I start to change the roundness and rotation of the brush either interactively or by the sliders. It always crashes - sometimes right away, sometimes later. But as far as I have noticed it can't last more than about 10 minutes of active brush usage. The crash is a white screen with the clock spinning and when I click the Vista message comes saying that Photoshop stop responding and need to close. I also tried a few times to wait for hours to see if it will come back after the white screen but it never did.
    Have you experienced or heard of this and some fixes?

    Update to Photoshop 11.0.1.
    And make sure your video card driver is up to date (check NVidia or ATI web sites).

  • Just updated to Yosemite and now can't open mail, or finder or others.  That wheel,just goes round and round

    i just updated to Yosemite and now can't open mail or finder or other apps.   Wheel just goes round and round

    I just uninstalled it and am waiting for it to reinstall. I sincerely hope that I have not lost everything that I worked on so hard. Now that mobile me is gone, I have not been able to go between devices to transfer things. I was merely trying to take a document I had worked on and open it in pages, but it said my version was too old. When I updated, it wouldn't load. Now I cannot do anything. I hope that the reinstall fixes it without losing everything. Please advise!!! Yes, I am in panic mode.

Maybe you are looking for

  • Preview Email Attachment

    When i recieve an email with an attachment i will preview it by highlighting the attachment and using the space bar to show a preview.  Sometimes i will blow it up (pinch to zoom on my trackpad) but whenever i zoom it out, the screen will go black af

  • F110 Error-Pymt Methods for This Run Not Specified in Master Record

    Hi, I have encountered an issue where the payment program will not determine the payment method correctly.  We have several company codes assigned to a single paying company code.  We do not enter a payment method on the invoice.  The payment method

  • INTERNAL.AE ERROR

    Dear Collegues This is the error we could see in sxmb_moni, <!--  Call Adapter   --> - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">   <SAP:Category>XIServer</SA

  • Blackberry world connection error

    Good afternoon I am trying to access blackberry world but get the error 'an error has occurred and blackberry world must close. Try waiting a few minutes and then re-open Blackberry world'. I have seen several recommendations to turn off wifi but I a

  • System not suitable to install some games

    hey im a relative novice, but had no problem when i bought my laptop satellite pro a40 back in october last year. over the past few months i ve had the problem that some games cannot be installed as the message: '16 bit windows subsystem: the system