CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: What is the output of the following query
SELECT TRUNC(1234.5678,-2) FROM DUAL;

Answer: 1200.



Category SQL Interview Questions & Answers - Exam Mode / Learning Mode
Rating (1.0) By 536 users
Added on 10/12/2009
Views 11605
Rate it!
Question: What is the output of the following query
SELECT TRUNC(1234.5678,-2) FROM DUAL;

Answer:

1200. Source: CoolInterview.com


1200 Source: CoolInterview.com

Answered by: muragesh | Date: 7/15/2008 | Contact muragesh Contact muragesh

'trunc' is not a recognized built-in function name.so use select round(1234.5678,-2) from 'tablename'. this funtion work well. Source: CoolInterview.com

Answered by: R.lakshmi | Date: 2/7/2009 | Contact R.lakshmi Contact R.lakshmi

TRUNCATE (number):
When you specify a number as an argument, the TRUNCATE function truncates a number to a specified number of decimal places.

Return Value: DECIMAL
Syntax:TRUNC (number, truncvalue)
Arguments:number

The number to truncate. The value specified for number must be followed by a comma.
truncvalue

An INTEGER value that specifies the number of places to the right or left of the decimal point to which number should be truncated. When truncvalue is positive, digits to the right of the decimal point are truncated. When it is negative, digits to the left of the decimal point are truncated (that is, made zero). When truncvalue is omitted, number is truncated to 0 decimal places.
TRUNCATE (datetime)

The TRUNCATE (datetime) function returns date with the time portion of the day truncated to the unit specified by the format model.

Return Value

SECOND OPTION WITH DATE TIME:
DATETIME
Syntax: TRUNC (datetime_exp, [fmt])

Arguments: datetime-exp
A datetime expression that identifies a date and time number.
fmt

A text expression that specifies one of the format models shown in Table 8-6, "Datetime Format Templates for the ROUND and TRUNC Date Functions". A format model indicates how the date and time number should be truncated. If you omit fmt, then date is truncated to the nearest day.

Examples

Example 8-150 Truncating to the Nearest Year

When the value of the NLS_DATE_FORMAT option is DD-MON-YY, then this statement:

SHOW TRUNC (TO_DATE('27-OCT-92'),'YEAR')

returns this value: 01-JAN-92
Source: CoolInterview.com

Answered by: Muhammad Habshi | Date: 4/14/2009 | Contact Muhammad Habshi Contact Muhammad Habshi

Trunc will truncate the values upto certain decimal points

like in the example given

if decimal places is -ve ,trunc will replace the values to the left of decimal places to 0,
if the value + will trunc the valued to the right of decimal points Source: CoolInterview.com

Answered by: Jaspal Singh | Date: 7/30/2009 | Contact Jaspal Singh Contact Jaspal Singh

kindly can you justify your answer.
i need bit clarification on this.! Source: CoolInterview.com

Answered by: deepak | Date: 8/31/2009 | Contact deepak Contact deepak

1200 Source: CoolInterview.com

Answered by: ARAVIND | Date: 9/29/2009 | Contact ARAVIND Contact ARAVIND

The output will be 1200. Source: CoolInterview.com

Answered by: kultar kaur | Date: 11/9/2009 | Contact kultar kaur Contact kultar kaur

ans is 1200 as trunc (truncate) is used for truncation if you use -ve(-2) scale it will round 2 digit to 00 from "." if you use +ve(2) it will give 1234.56 will round up 2 digit from "." -> Source: CoolInterview.com

Answered by: vishnu | Date: 11/28/2009 | Contact vishnu Contact vishnu

SELECT TRUNC(1234.5678,-2) FROM DUAL

Result will be 1200 Source: CoolInterview.com

Answered by: sayed jafar | Date: 11/30/2009 | Contact sayed jafar Contact sayed jafar

1200
if the -ive parameter is passed under TRUNC function truncation will be used to below decimal place i.e
-1 means Trunc to 10th (1234 becomes 1230)
-2 means trunc to 100th (1234 becomes 1200)
-3 means trunc to 1000th (1234 becomes 1000)
Source: CoolInterview.com

Answered by: archana vashist | Date: 12/1/2009 | Contact archana vashist Contact archana vashist

It return 1200 Source: CoolInterview.com

Answered by: shalaj | Date: 4/30/2010 | Contact shalaj Contact shalaj

trunc' is not a recognized built-in function name.so use select round function.

SELECT round(1234.5678,-2) FROM DUAL
if the -ive parameter is passed under round function truncation will be used to below decimal place i.e
-1 means round to 10th (1234 becomes 1230)
-2 means round to 100th (1234 becomes 1200)
-3 means round to 1000th (1234 becomes 1000) Source: CoolInterview.com

Answered by: Prakash | Date: 7/8/2010 | Contact Prakash Contact Prakash

-1 means Trunc to 10th (1234 becomes 1230)
-2 means trunc to 100th (1234 becomes 1200)
-3 means trunc to 1000th (1234 becomes 1000)



Source: CoolInterview.com

Answered by: khusboo | Date: 9/10/2010 | Contact khusboo Contact khusboo


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All SQL Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.03125 Seconds