October 27, 2015 at 10:16 am
Hi,
Can someone please explain why this is happening.
I am using a select query to do the following;
SUM(CASE WHEN [Measure] = 'XXX' THEN 1 ELSE 0 END) AS 'SEN-04'
The numbers are then inserted into a temp table and looking at the temp table it is only showing whole numbers. I then insert the data into an audit table and it represents the numbers as 0.00.
This has been doing my head in all day. I have tried Cast() and Convert() with no luck.
Thanks in advance for any help.
October 27, 2015 at 10:20 am
what is the field definition of the audit table set as?
October 27, 2015 at 10:21 am
dramaqueen (10/27/2015)
Hi,Can someone please explain why this is happening.
I am using a select query to do the following;
SUM(CASE WHEN [Measure] = 'XXX' THEN 1 ELSE 0 END) AS 'SEN-04'
The numbers are then inserted into a temp table and looking at the temp table it is only showing whole numbers. I then insert the data into an audit table and it represents the numbers as 0.00.
This has been doing my head in all day. I have tried Cast() and Convert() with no luck.
Thanks in advance for any help.
What is the data type of 'SEN-04' in the audit table?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 27, 2015 at 10:23 am
Here is the design view of the audit table. I am putting the data into the value field.
October 27, 2015 at 10:29 am
dramaqueen (10/27/2015)
Hi,Can someone please explain why this is happening.
I am using a select query to do the following;
SUM(CASE WHEN [Measure] = 'XXX' THEN 1 ELSE 0 END) AS 'SEN-04'
The numbers are then inserted into a temp table and looking at the temp table it is only showing whole numbers. I then insert the data into an audit table and it represents the numbers as 0.00.
This has been doing my head in all day. I have tried Cast() and Convert() with no luck.
Thanks in advance for any help.
What is the schema for the temp table?
Don Simpson
October 27, 2015 at 10:29 am
dramaqueen (10/27/2015)
Here is the design view of the audit table. I am putting the data into the value field.
Can you post the code?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 27, 2015 at 10:31 am
*** removed double post.
Don Simpson
October 28, 2015 at 3:03 am
I have stripped some of the code out that is irrelevant but here is what its doing.
IF OBJECT_ID('tempdb.dbo.##TempTable1', 'U') IS NOT NULL DROP TABLE ##TempTable1
SELECT
SUM(CASE WHEN [Measure] = 'XXX' THEN 1 ELSE 0 END) AS 'SEN-04'
INTO ##TempTable1
FROM [SERVER].[DB].[dbo].
INSERT INTO [SERVER].[DB].[dbo].
SELECT , [MONTH], [SEN-04] AS [Value], 'SEN-04' AS [Measure], GETDATE() AS [Inserted] FROM ##TempTable1
October 28, 2015 at 4:54 am
I have worked it out! It was something to do with a later statement being CAST().
Thanks everyone.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply