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

  • SEARCH
  • Home
  • 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 7961227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:58:45+00:00 2026-06-04T04:58:45+00:00

I have run a SQL query in SQL Server Management Studio 2005 and when

  • 0

I have run a SQL query in SQL Server Management Studio 2005 and when my results come through my Total_Cost column is not formatted as I want.

I have tried adding in a Declare @TOTAL_COST decimal(12,2) clause but cannot seem to get this to work so have taken it out again.

My query is:-

SELECT     
   vwREP_GP_ContractProjectPurchaseCostCatID.PACOSTCATID AS COST_CAT_CODE, 
   vwREP_GP_ContractProjectPurchaseCostCatID.PACOSTCATNME AS COST_CAT_NAME, 
   vwREP_GP_ContractProjectPurchaseRpt.COST, 
   vwREP_GP_ContractProjectPurchaseRpt.ITEMDESC AS ITEM, 
   vwREP_GP_ContractProjectPurchaseRpt.CREDITOR, 
   vwREP_GP_ContractProjectPurchaseRpt.DOC_NUM AS DOCUMENT_NUMBER, 
   vwREP_GP_ContractProjectPurchaseRpt.DESCRIPTION, 
   vwREP_GP_ContractProjectPurchaseRpt.DOC_DATE AS DATE,  
   vwREP_GP_ContractProjectPurchaseRpt.PROJECT AS JOB_CODE_STAGE, 
   vwREP_GP_ContractProjectPurchaseRpt.COMPOUNDNAME AS CATEGORY_DESCRIPTION
FROM         
   vwREP_GP_ContractProjectPurchaseCostCatID 
INNER JOIN
   vwREP_GP_ContractProjectPurchaseRpt ON vwREP_GP_ContractProjectPurchaseCostCatID.PACOSTCATID = vwREP_GP_ContractProjectPurchaseRpt.PACOSTCATID

SELECT  
   CATEGORY_DESCRIPTION, SUM(COST) AS TOTAL_COST 
FROM    
   (SELECT 
        COMPOUNDNAME AS CATEGORY_DESCRIPTION, COST 
    FROM   
        vwREP_GP_ContractProjectPurchaseRpt 
   ) A
GROUP BY 
    CATEGORY_DESCRIPTION 

This gives me the results I am looking for but the Total_Cost produces numbers in a 5 decimal format.

For example:

156713.55000

What is the best way to get the result to read something along the lines of –

156713.55

Thanks in advance

  • 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-06-04T04:58:47+00:00Added an answer on June 4, 2026 at 4:58 am
    SELECT     vwREP_GP_ContractProjectPurchaseCostCatID.PACOSTCATID AS COST_CAT_CODE, 
               vwREP_GP_ContractProjectPurchaseCostCatID.PACOSTCATNME AS COST_CAT_NAME, 
               vwREP_GP_ContractProjectPurchaseRpt.COST, 
               vwREP_GP_ContractProjectPurchaseRpt.ITEMDESC AS ITEM, 
               vwREP_GP_ContractProjectPurchaseRpt.CREDITOR, 
               vwREP_GP_ContractProjectPurchaseRpt.DOC_NUM AS DOCUMENT_NUMBER, 
               vwREP_GP_ContractProjectPurchaseRpt.DESCRIPTION, 
               vwREP_GP_ContractProjectPurchaseRpt.DOC_DATE AS DATE,  
               vwREP_GP_ContractProjectPurchaseRpt.PROJECT AS JOB_CODE_STAGE, 
               vwREP_GP_ContractProjectPurchaseRpt.COMPOUNDNAME AS CATEGORY_DESCRIPTION
    
    
    FROM         vwREP_GP_ContractProjectPurchaseCostCatID INNER JOIN
                          vwREP_GP_ContractProjectPurchaseRpt ON vwREP_GP_ContractProjectPurchaseCostCatID.PACOSTCATID = vwREP_GP_ContractProjectPurchaseRpt.PACOSTCATID
    
    
    
    SELECT  CATEGORY_DESCRIPTION, CAST(SUM(COST) AS DECIMAL(12, 2)) AS TOTAL_COST
    
    FROM    (  
            SELECT COMPOUNDNAME AS CATEGORY_DESCRIPTION, COST 
            FROM   vwREP_GP_ContractProjectPurchaseRpt 
            ) A
    GROUP BY 
            CATEGORY_DESCRIPTION     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have using aqua data studio to run my query from sql server 2005.
I'm using microsoft SQL server management studio 2005 I'm trying to run a job
We have a query that takes 2 seconds to run in Sql Server Management
Little background: Recently I upgraded SQL server management studio 2005 by applying the patch
I am using Sql Server Management studio and I'm running a query with a
I have a stored procedure that executes much faster from Sql Server Management Studio
I have code to run sql query in ruby as follows sql = ActiveRecord::Base.connection()
I have a custom SQL query that I run with this line: @avg_score =
As I had written in title, I have SQL query, run on Oracle DB,
I have a java.sql.ResultSet object containg data from a query that was run. How

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.