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 the following table DROP TABLE IF EXISTS `test`.`foo`; CREATE TABLE `test`.`foo` (
Hi I have the following query running a function to get the Standard Deviation
I have the following XML (simplification): <?xml version=1.0 encoding=utf-8?> <TestCases> <TestCase> <Name>Test1</Name> <Result>Failed</Result> <Properties>
I have a problem with the following MySQL query: SELECT * FROM TPDSessions WHERE
setup: mysql> create table product_stock( product_id integer, qty integer, branch_id integer); Query OK, 0
setup: mysql> create table product_stock( product_id integer, qty integer); Query OK, 0 rows affected
setup: create table product_stock(product_id integer, qty integer, branch_id integer); create table product(product_id integer, product_name
I have a problem of listing duplicated rows that include NULL columns. Lemme show
Greetings, I have a problem as follows: I have an SQL variable declared: DECLARE
I have a question about SQL Server indexes. I'm not a DBA and assume

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.