.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Rounding the Percentage Value

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :Sql Server

I have calculated a percentage in TSQL, which the output looks like this


This is then converted to a percentage in SSRS 2005, which looks like this


How do i within TSQL use the result from the percentage calculation to work out the percentage... so for example, I would update Col2 using Col1, so the results looks like this..



View Complete Post

More Related Resource Links

Rounding a number based upon it's midpoint


I need to round down, or round up a floaitng point number to it's closest integer value.
So for example 3.49999 is closer to 3 so it would round down to the integer 3.
3.5002 is closer to 4 so this would round up to the integer 4.

I do not need to be concerned negative numbers. Can someone show me how to do this?


Here are more examples to make clear what I am talking about



Help: Rounding off numbers

I'm having some problems when it comes to rounding off numbers. In the reports I build the users wants to see the numbers in M$ or k? . that is Million$ or kilo?. So what I do is take the money and divide it by 1.000.000 or just by 1.000. The thing is that if a number is 750.000 and I divide it by 1.000.000 it should say 0,75M? for example. But nooo, it says 1M?, and that's not right. Any suggestions?  Thanks in advanced

Reports in Percentage

Hi ALL, I have scheduled hours of each employee for each week and no of days scheduled in a week.i want to get reports for weekly wise no of employees scheduled less 24 hrs per week,b/w 24 and 48 hrs and greater than 48 hrs       Scheduled Hrs              8/1/2010         8/8/2010        15/8/2010            22/8/2010 Less than 24 hrs               5%                      5%                       5%                          4%   b/w 24 and 48 hrs          4%                        6%                    &

Calculating percentage of sceduled hours

 Hi all,       I want to calcultae how many employees are scheduled less 24 hrs for each week,b/w 24 and 48 and greater than 48         In excel file i have weekly wise total hours scheduled for each employee  and total no of days scheduled in week(example 6 days and 1 off)which i will upload it to database,based on this i want to display reports  in bound controls Result should be like this                    Scheduled Hrs      8/1/2010        8/8/2010       8/15/2010       8/22/2010                  Less than 24 hrs     5%                       5%                  5%                   5%        Between 24 and 48 hrs    5%         

wrong Percentage calculation showing in pie chart

Hi,       Im using "#PERCENT{P2}" this one to calculate percentage in pie chart.  It should take 2 decimal only rite? But it is taking 3 decimal values. Example: 20.90678 After applying the formula "#PERCENT{P2}"  it is showing as 20.91 i want to show as 20.90 only pls help me Thanks in advance, Abdul2010

Percentage of matching days off among employee's

Hi All,i have Intime and Outtime of each employee for all the days of 1st,2,3,4 week.There will be a off for 1 day or 2 days for each employees.Based on this i need to calculate consisitency days off assignmanet i.e no of matching days off among employees in percentage.If there are 100 emplyees out of 100 employees 50 people may get week off on the same day(for example sunday). I want result in percentage.result like thisConsistency Days of assignment            Across 4 weeks            3 weeks                2weeks                0                                                             2%                                   0%     &

Pie show percentage greater than 100%

Hi all , i have a pie chart and show percentage as label ,i set label data as #PERCENT{P0} but when report runs it has 3 value: 58%,11%,32% you can see the 3 value add up to 101% is something else i need to set on label ? any help for this ?

Add percentage subtotal to Matrix

I know this question has been asked many times but I can't seem to find a solution that works for me. I have a matrix as follows with two row groups (provider and hospital) and one column group (mix type). The matrix looks like this:     CKD ESRD PRIOR TOTAL Dr. Amin Arrowhead Hospital 2 3 1 6 Central 0 1 4 5 Westview 1 1 3 5 SUBTOTAL 3 5 8 16 Dr. Sacks Arrowhead Hospital 4 1 2 7 Central 2 2 4 8 Westview 0 4 1 5 SUBTOTAL 6 7 7 20 TOTAL 9 12 15 36 PCT 25% 33% 42% The PCT row is the subtotal row I'm trying to add to the matrix. I've tried adding a third row group and using the InScope function but I can not get it to produce the desired results below the subtotal row. Thanks in advance for any suggestions anyone can offer.                       

Percentage Calculation in T-SQL

Hello T-SQL people,   I need help on the above subject. I have two tables, the name of the first one is Productions with 3 fields namely: agentid,amountproduced,datesold then the second table name is budget with 3 fields namely: agentid, yearbudgetamount, budgetyear, now what i want now is that i want to calculate the percentage of each agent on  amountproduced as against the yearbudget, it must be within that budgetyear. Please I need Idea.   Thanks in advance!

Calculating a Percentage Value in SQL

Hey, I'm trying to calculate a percentage value in SQL. The following is my full stored procedure with sample data, if you run it you will see that I get one result which is grouped per Policy with a total for hrs_on and a total for hrs_hibernated, to calculate my percentage I need to use the following formula total_hrs_hibernated / total_hrs_on * 100 My problem is I can actually get the percentgae working fine if I do it for each individual record, if you run "Select * from #hibernatetemp" you will see my results with the percentage which are correct. I however need to group my results per policy and I'm not sure how to get the calculations to work correctly when I group by policy etc.  Would appreciate any help or advice on the method to do it as I may be over thinking this and trying to do it a more difficult way, Thanks    CREATE PROCEDURE [dbo].[SP_TEST_TEST2] AS /* Create temp table */ CREATE TABLE #hibernatetemp ( on_time datetime NULL, hibernate_time datetime NULL, startup_after_hibernate datetime NULL, off_time datetime NULL, sub_policy_name varchar(50), total_hrs_on decimal(18, 0), total_hrs_hibernated decimal(18, 0), hibernate_percentage decimal(18, 0) ) /** Insert Values into Temp Table from View, including Day/Night Rates*/ insert into #hibernatetemp (on_time, hibernate_time, startup_after_hi

Rounding problem for money output parameter from stored proc

I have a GridView sourced by a SQL Server stored procedure with several databound fields, including a money column for item values. My stored proc returns the data through a SELECT and everything looks good. The stored proc also has a single output parameter that sums the total value of the displayed data, and this value is displayed in a label above the GridView. The output parameter (defined as money on the SQL Server side) is passed back to the app in good shape, but is rounded when displayed in the DataSource_Selected event handler. So a total of $30,155.22 in SQL Server shows up as $30155 on my aspx.In debugging, I have confirmed that the value leaving SQL Server is correct (30155.2200), and I can see that the value coming IN to the ASP-side event handler is already rounded. What do I need to do here to coerce/force it to show as money/currency?Relevant snippets:Stored Proc:... @onHandValue money OUT...  CREATE TABLE #tempValueOnHand(... valueOnHand money )... set @onHandValue = (select round(sum(valueOnHand), 2) from #tempValueOnHand) set @onHandValue = (select sum(valueOnHand) from #tempValueOnHand)And again, the output parameter @onHandValue is coming back, just already rounded.On the ASP side:    Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSourc

Help with Percentage Counts for Prior 3 months

I am trying to calculate the counts of issues for the prior 3 months as a percent of the total of all issues for the prior 3 months. eg. For Sept. I would need the counts for Jun, Jul, Aug for each issue type divided by the total number for all issue types for those 3 months..

For the numerator I used the following and have confirmed that it is correct via SQL queries. 

CREATE MEMBER CURRENTCUBE.[Measures].[PctUniqueIssuesNumerator] AS Aggregate
( {[IssueDate].[ProgMonth].CurrentMember.Lag(3) : [IssueDate].[ProgMonth].CurrentMember.Lag(1)}
    [InvoiceIssueType].[Invoice Issue Type].CurrentMember
    [Measures].[Invc Id Distinct Count - IssueFact]

For the denominator I am using this MDX but doesnt seem to be correct. Should I be doing it differently? I need the sum of [Invc Id Distinct Count - IssueFact] for all issues types for the prior 3 months.

CREATE MEMBER CURRENTCUBE.[Measures].[PctUniqueIssuesDenominator] AS Sum(
    DESCENDANTS([InvoiceIssueType].[Invoice Issue Type].[All],1),

LIKE Condition - Single Percentage Sign Matching?


What is the expected behavior when a LIKE condition specifies a single percentage sign? For example, if I have a Customer table with a CustomerName field and I write the following SQL Query:

SELECT * FROM Customer WHERE CustomerName LIKE '%'

  1. Does the single percentage sign negate the LIKE condition?
  2. Would this specific statement be equal to just SELECT * FROM Customer?
  3. Finally, does this work with all data types, or just char/nchar/varchar/nvarchar?

Use one cell`s value onto aother Cell to calculate percentage in SSRS 2008


Pls help me with my below issue.


I developed SSRS 2008 Matrix Report.

In one of the Rows in the Matrix, First Rows Represent Percentage of Subtotal of Second Rows's Value.In my Matrix , total i have 4 Rows, one of Row need to show a Percentage of Subtotal of Another Row.

How can i Reference that Row Values / Matrix subtotal Values Like that ?

Below is formate of my Matrix SSRS 2008 Report.

Jan Feb March

Mumbai 48% 51% 41% <---Represent of Second Row - Bangalore Percentage of Subtotal

Bangalore 135 192 197

Delhi 149 185 278

Total 284 377 485

How can i reference, One Cell Value from other Cell's and Subtotal for the Percentage Calculation in SSRS 2008 Matrix ?

I would like to calculate percentage for banglore. Such as 135/284.. do you kno what i mean.

Please help me!!

Let me know if need information.



Select Statement - Random and Percentage


 I have a question about a select statement.  Currently I have a select statement that does what I want it to do, but it needs to be altered, giving my WHERE options an equal chance to show.


SELECT TOP 1 *, NEWID() as Random

It seems to work pretty well for the purpose.  Often I will need 3 to 6 different Code types.  What I need it to do is give each CODE type an equal oportunity to display.

For instance:


I'd like them to, in this instance, have a 33% to show.  More or less, I'd like, 1 of AB, ABC, ABCD, then I want them to randomize agian. 

If I have  4 Code types, I'd like a Select statement to grab 1 of each, and give them a 25% chance to show, by randomizing those 4.

Please Advise.


AsyncFileUpload+progress percentage


Hi friends...

Is There a code to monitor the progress (how much % is completed-graphically) of uploading with AsyncFileUpload Control ?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend