Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:40:00+00:00 2026-05-20T09:40:00+00:00

I have the following Query: create table #Result (Reward varchar(40), Value MONEY); insert #Result

  • 0

I have the following Query:

create table #Result (Reward varchar(40), Value MONEY);

insert #Result exec GetCurrentCycleQualifierStatusByAccountId @AccountId=76011;

with cteFirstResults as
(select Reward, round(Value,2) as Value from #Result where Reward like '%Balance%'), 
cteSecondResults as
(select Reward, convert(INTEGER, Value) as Value from #Result where Reward NOT like    '%Balance%')

select * from cteFirstResults 
UNION ALL
select * from cteSecondResults;

drop table #Result;

When running a select * individually against each “cte” table, I get the results I want.
But when run all together, I get something like:

Reward          Value
------          -----
Daily Balance   4709.00
Value A         1.00
Value B         9.00

I want the Value A/Value B data to show without any decimal values as they do when running a select against the table directly. How do I combine the two queries into one to show this data correctly?

Round(value,0) does nothing.

I can not change the sproc from which I’m gathering the data, but I can make the temp table any way I like.

Thanks,

Jason

The solution:

create table #Result (Reward varchar(40), Value MONEY);
insert #Result exec GetCurrentCycleQualifierStatusByAccountId @AccountId=76011;
With cteFirstResults as
(
Select Reward, Value
From #Result 
Where Reward like '%Balance%'
)
,  cteSecondResults as
(
Select Reward, cast(Value as int) as Value
From #Result 
Where Reward Not like '%Balance%'
)
Select Reward, Cast( Value As varchar(max)) As Value
From cteFirstResults 
Union All
Select Reward, Cast( value As varchar(max)) as Value
From cteSecondResults;
drop table #Result;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:40:00+00:00Added an answer on May 20, 2026 at 9:40 am

    The problem is the integers are being implicitly cast to decimal because they are being represented in a decimal column.

    If you just want the values displayed, cast them both to strings.

        CREATE TABLE #test
    (
        test decimal(9,2)
    )
    
    CREATE TABLE #test2
    (
    test int
    )
    
    INSERT INTO #test (test)
    SELECT 1.25 UNION ALL
    SELECT 172813.99
    
    INSERT INTO #test2 (test)
    SELECT 134 UNION ALL
    SELECT 41
    
    SELECT CAST(test as  varchar(max)) FROM #Test
    UNION ALL
    SELECT CAST(test as  varchar(max)) FROM #Test2
    

    Results:

    1.25
    172813.99
    134
    41
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a DB2 query to do the following: Create a temp table
I have the following scheme: CREATE TABLE IF NOT EXISTS `connections` ( `username1` varchar(15)
I have the following: CREATE TABLE food_delivery ( foodtype varchar(50) NOT NULL, foodname varchar(50)
I have the following tables: create temporary table Items (item_id int, item_name varchar(10)); create
I have following query in which data is coming from a table and in
Hi I have the following table: CREATE TABLE #Test ( ProductID int, MainMasterFeatureID int,
My table have following columns, (copy to create test table) CREATE TABLE dbo.[PDNApprovalDetail]( [PDNApprovalMasterID]
I have problems to query my data. Here are my tables: CREATE TABLE `A`
I have a MySQL table with following setup: CREATE TABLE IF NOT EXISTS `coords`
I have tables with following structure: -- Table structure for table `temp_app` -- CREATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.