Home » SQL & PL/SQL » SQL & PL/SQL » Query
Query [message #230631] Thu, 12 April 2007 06:41 Go to next message
namrata_bhise
Messages: 18
Registered: October 2006
Location: mumbai
Junior Member
Hi,

While studing for certification I encountered a query, which I can't understand.

Kindly help me to understand the below query with the expected output.
Embarassed


SELECT ROUND(TRUNC(MOD(1600,10),-1),2)

Regards
Namrata

Re: Query [message #230632 is a reply to message #230631] Thu, 12 April 2007 06:46 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
What part are you having trouble with: MOD, TRUNC or ROUND?

MHE
Re: Query [message #230633 is a reply to message #230631] Thu, 12 April 2007 06:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> SELECT ROUND(TRUNC(MOD(1600,10),-1),2)
  2  /
SELECT ROUND(TRUNC(MOD(1600,10),-1),2)
                                     *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

In Oracle FROM <something> is mandatory.
So what you posted only returns an error.

Beside, you can read trunc and round and mod pages of documentation.

Regards
Michel

[Updated on: Thu, 12 April 2007 06:48]

Report message to a moderator

Re: Query [message #230634 is a reply to message #230631] Thu, 12 April 2007 06:53 Go to previous messageGo to next message
namrata_bhise
Messages: 18
Registered: October 2006
Location: mumbai
Junior Member
The query is like this-


SELECT ROUND(TRUNC(MOD(1600,10),-1),2)
FROM dual;
I know about ROUND,TRUNC,MOD function but never used alltogether.

Regards
Namrata
Re: Query [message #230636 is a reply to message #230634] Thu, 12 April 2007 06:58 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
It is not that hard: the result of MOD will be passed to TRUNC that will pass its result to ROUND. It is not different from other languages. Break it down to have a close look.

MHE
Re: Query [message #230657 is a reply to message #230631] Thu, 12 April 2007 09:12 Go to previous message
Ericle
Messages: 44
Registered: April 2006
Location: United States of America ...
Member

Like he said, you have to break it down to see what it's doing. First, determine the value for MOD(1600,10). Let's say that value is called value1. Then determine the value of TRUNC(value1,-1). Let's say that is called value2. Then you determine ROUND(value2,2). Then you can understand how it comes up with the output that you see.
Previous Topic: Error - trying to drop and add a primary key
Next Topic: Session out after 30 min.
Goto Forum:
  


Current Time: Thu Dec 08 20:28:05 CST 2016

Total time taken to generate the page: 0.21379 seconds