Advertisement

04.17.2008 at 05:37PM PDT, ID: 23332931
[x]
Attachment Details

"CREATE TABLE table1 AS" is truncating decimals!

Asked by Miss_Sellaneus in Oracle Database

I have a statement similar to this:
CREATE TABLE table1 AS SELECT agent_id, SUM(face_amount) AS sum_face, SUM(fees) AS sum_fees FROM transactions GROUP BY agent_id;

transactions.face_amount and transactions.fees have precision 2 places to the right of the decimal. But when I do my CREATE TABLE, it rounds the sums to integers! If I do my SELECT without the CREATE TABLE, I get sums with 2 decimal places.

How do I get it to put those 2 decimal places into the table? I have tried tricks such as
CREATE TABLE table1 AS SELECT agent_id, SUM(face_amount * 1.00) AS sum_face,
and
CREATE TABLE table1 AS SELECT agent_id, SUM(face_amount + 0.00) AS sum_face,
but still I am left with only integers. Is there any way to get the decimal precision into the table without having to first define the table, and then use INSERT?

Start Free Trial
 
Loading Advertisement...
 
[+][-]04.17.2008 at 05:48PM PDT, ID: 21382565

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 05:51PM PDT, ID: 21382571

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Sign Up Now!
Solution Provided By: aiklamha
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628