sql,sql-server,count,division,percentage

You need conditional Aggregate to find the percentage of output start with 'RT @' SELECT ( Count(CASE WHEN tweet LIKE 'RT @%' THEN 1 END) / Cast(Count(*) AS NUMERIC(10, 2)) ) * 100 FROM temp ...

Other than setting component sizes as percentage of parent, I do not think ther is another way.

c#,sql,asp.net,gridview,percentage

You should be able to just add a new column at the end of your select statement something similar to sum(table_a.col1) + sum(table_b.coly) as SubTotal Then just do the same sort of thing for your percentage column just figure out how to calculate the percentage....

css,resize,height,width,percentage

Any percentile value is relative to the size of the viewport. Viewport Height (VH) and Viewport Width (VW) are also relative. If you want to ensure your elements are always the same size, use an EM value.

css,image,percentage,dynamic-resizing

OK, so I am using this JQuery to do the resizing for me now, with the above CSS in a wrapper. <script> $( document ).ready(function() { if (document.documentElement.clientWidth < 700) { $("img").hide(); } $( window ).load(function() { if (document.documentElement.clientWidth < 700) { $('img:not(".noScale, .subLogo")').each(function() { $( this ).css("width", "auto" );...

This should be achievable simply with COUNTIF. https://support.office.com/en-us/article/COUNTIF-function-e0de10c6-f885-4e71-abb4-1f464816df34 Formulas: E1 =SUM($E$2:$E$10000) E2 downwards as needed: =COUNTIF($B:$B,$D2) F1 downwards as needed: =$E1/$E$1 ...

r,function,matrix,percentage,na

I was over thinking it. Below is my new function. a<-A[!is.na(as.vector(A))] # A, B, C, D are matrices with NA values b<-B[!is.na(as.vector(B))] c<-C[!is.na(as.vector(C))] d<-D[!is.na(as.vector(D))] mm<-function(x){mean(x==1)} # make percentage function Item.1<-lapply(data.frame(a,b,c,d), mm) # apply function to matrices ...

M.Ali's answer could be modified as select Cast(Cast((37.0/38.0)*100 as decimal(18,2)) as varchar(5)) + ' %' as Percentage ...

sql-server,sum,data-warehouse,percentage

you can use Running Total query and use your returned table as sub query as the following: SELECT [DimOrganization].OrganizationName , Value from ( SELECT x, Value, (SELECT SUM(Value) FROM (select top 10 [FactFinance].[OrganizationKey] as x,SUM([Amount]) as [Amount] , SUM([Amount]) / (select sum([Amount]) from [FactFinance])as Value FROM [FactFinance] group by([FactFinance].[OrganizationKey]) order...

You should use CONCAT in MySQL to concatenate % with the values received from ROUND(<...>) : CONCAT(ROUND(qy.TotalUnits/qy.TotalCalls *100),'%') At first, in MySQL + is used for arithmetic operations, secondly, you are trying to concatenate % with the alias, not values. ...

r,plot,percentage,scatter-plot,uncertainty

Are you thinking of the confidence interval for binomial proportion? see http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval E.g. binom.test(208,14824) the 95% CI is [1.22, 1.61] for your sample estimate 1.40 (percentage)

c#,.net,arrays,percentage,equivalence

The question is poorly defined, so I've taken some broad assumptions, but here's a sample implementation that measures equivalence based on element equality: int[] a = new int[] { 1, 2, 3, 4, 5 }; int[] b = new int[] { 1, 7, 3, 4 }; int equalElements = a.Zip(b,...

xcode,swift,if-statement,conditional,percentage

You can use arc4random_uniform to create a read only computed property to generate a random number and return a boolean value based on its result. If the number generated it is equal to 1 it will return true, if it is equal to 0 it will return false. Combined with...

r,loops,time-series,intervals,percentage

The R time series method ts, which you're trying to use, may be appropriate when there are an equal number of values per unit of time as in the case of months and years where there are 12 months in every year. However, since the number of days in a...

MySQL is calculating it correctly. Your percentage growth calculations (your comments) look odd. E.g. your first example: start value 68, current value 1. (68/1)*100 = 6800. If you want 68% growth, then your start value would need to be 1.68, not 68, which would make start value 168% of current...

Why don't you just implement a low-pass filter? For every successfull transfer, you push in a 1, for every failed one a 0; the result is a number between 0 and 1. Assuming that your transfers happen periodically, this works well -- and you just have to adjust the cutoff...

You're way over thinking it. double CalculateChange(long previous, long current) { if (previous == 0) throw new InvalidOperationException(); var change = current - previous; return (double)change / previous; } To display this data to a user in a friendly 'percentage' format, you can use: string DoubleToPercentageString(double d) { return "%"...

unix,lines,percentage,head,tail

You can modify the awk to head the file itself: sort -n -k 3 /Desktop/Results.xls| awk '{a[i++]=$0}END{for (j=1;j<=i/10;j++){printf "%s\n",a[j]}}' >./Results_0167_1.xls The awk stores and counts ( a[i++]=$0 ) the records piped by sort, after this process , in the END part it will print the recors till 10% is reached:...

That's because % values on margin doesn't refer to the height of the element. Refer to the width of the containing block In this case will be the width of the body tag. With the next snippet you can try open in full page and resize the width of your...

json,excel,percentage,transpose,roundup

Set the number format to 0.0\% If you want to display two decimal places after the percentage, use 0.00\% instead. Credit: http://jolleytrails.blogspot.com/2010/04/how-to-add-percentage-sign-without.html Alternatively, add this after you initialize toonInfo for(var i=0; i<toonInfo.length; i++) { toonInfo[i] *= .01; } Then set the number format to percentage when storing in excel. ...

Use DecimalFormat.. Example: DecimalFormat df = new DecimalFormat("###.####") // <- "###.###" specifies precision double x = 143.13; double y = 23.12; double answer = x / y; System.out.println("Answer: " + df.format(answer)); ...

If columnWidth is not set, Masonry will use the outer width of the first element. This explains why each element was in new row, they all had 100% width. It is convenient to use external CSS class to set size of the column. It is also important to set...

You're treating % as part of the "string" that you're printf()'ing Pass the actual numeric value as the argument to printf(), and include the percentage sign in the "mask" (it needs to be escaped with another % character) <?php printf( __( '%.0f%%' ), $mini_deck->rating_per ); ?> ...

Here are the things you need to add: html, body { height: 100%; } .container { height: 100%; } Demo here: http://jsbin.com/tiyihigi/2/ Code here: http://jsbin.com/tiyihigi/2/edit?html,css...

Math.floor(Math.random() * 100) + 1 + '%' ...

I would suggest you to use some external script for such kind of preprocessing (you can also do this on-the-fly). Yes, you can do this in gnuplot in two steps, but can become quite complicated and requires some more profound knowledge of gnuplot. Here is a working script, but I...

Try this: declare @maxcount1 float declare @maxcount0 float select @maxcount1 = max(count1), @maxcount0 = max(count0) from (SELECT TeamName,Count(DISTINCT CASE WHEN WorkInfo = 1 THEN SlNo end) AS Count1 , Count(DISTINCT CASE WHEN WorkInfo = 0 THEN SlNo end) AS Count0 FROM tableA WHERE (SubmitDate BETWEEN @start AND @end) GROUP BY...

Define a function an apply it on each row of your data.frame: fun <- function(vec) { n = length(vec) if(all(is.na(vec))) return(rep(FALSE,n)) noNA = vec[!is.na(vec)] if(length(unique(noNA))==1) return(!is.na(vec)) res = rep(FALSE, n) for(i in 1:n) if(any(abs(vec[i]-vec[-i])<=vec[-i]*0.1, na.rm = TRUE)) res[i] = TRUE res } output=data.frame(t(apply(dataDF,1,fun))) names(output) = names(dataDF) output Gives the wanted...

python,math,percentage,filesize,ratio

Those sizes are integers, so Python is performing integer division. Try converting the sizes to floats first: file1Size = float(os.stat(file1).st_size) file2Size = float(os.stat(file2).st_size) In integer division, 1 / 2 is 0. But with floating pointer numbers, 1.0 / 2.0 will be 0.5....

Try: SUM(callers_total) / SUM(a.start_reached_speech_mobile + a.start_reached_speech_landline + a.start_reached_text + a.start_reached_email) ...

Its simple maths: var res=(current-june)/current*100.0; ...

There is no padding in percent that will make the larger square twice as high as the regular squares. A regular square is one character block high, plus 4.54% of the parent element width. For the larger square to be twice as high, it needs to be two character blocks...

You want to make your division a floating point division : totalScore = (double)j * 100 / resultString.length(); That's assuming totalScore is a double. Otherwise, j * 100 / resultString.length() would use int division, so if resultString.length() > 100, the result would be 0. As Tom mentioned, the condition of...

android,sqlite,aggregate-functions,percentage

Please try the following code SELECT pkg,ROUND((count(*)*100)/(SELECT count(*) FROM reg)) as percentage FROM reg group by pkg Try is yourself on SqlFiddle...

You could try v2 <- as.numeric(substr(v1, 1,4)) v1[] <- ifelse(v2==0, sprintf('%.1f%%', v2), sprintf('%.2f%%', v2)) v1 # age workclass fnlwgt education education-num # "0.0%" "5.63%" "0.0%" "0.0%" "0.0%" # marital-status occupation relationship race sex # "0.0%" "5.66%" "0.0%" "0.0%" "0.0%" # capital-gain capital-loss hours-per-week native-country prediction # "0.0%" "0.0%" "0.0%" "1.79%"...

If you are just looking to roll a random percentage, you can use the Random class in java. Random rand = new Random(); Double pickedNumber = rand.nextDouble(); Running that, will result in pickedNumber being some double between 0 and 1. For example: 0.3650998187710377 Then check if that percentage is less...

c,percentage,integer-overflow,integer-division

Diagnosis The value you expect is, presumably, 91. The problem appears to be that your compiler is using 16-bit int values. You should identify the platform on which you're working and include information about unusual situations such as 16-bit int types. It is reasonable for us to assume 32-bit or...

php,smarty,percentage,php-5.4,smarty2

If you really want to do this within the Smarty template, you can solve it like this (slightly simplified): {assign var="real_count" value="3"} {math equation="x + (x * y)" x=$real_count y=0.65 format="%.2f"} However, I would usually advise against doing too much math and other logic in a template. In most use...

Assuming that you want to get the rowSums of columns that have 'Windows' as column names, we subset the dataset ("sep1") using grep. Then get the rowSums(Sub1), divide by the rowSums of all the numeric columns (sep1[4:7]), multiply by 100, and assign the results to a new column ("newCol") Sub1...

html,css,navigation,width,percentage

Add width: 100%; to ul#menu. Check it our here: https://jsfiddle.net/vjhz7o8y/5/. Also, avoid using the same id for multiple elements, use class instead. ul#menu { height:25px; width:100%; float:right; margin:0; padding:0; list-style-type:none; background:#44546A; } ...

actionscript-3,flash,function,percentage

You're almost there. When a method returns a value, you can asign it to a variable of type that it returns var percentage:Number = valueToPercent(45, 0, 345); trace(percentage); and/or trace(valueToPercent(45, 0, 345)); ...

css,percentage,background-position

Solving the problem After some fiddling I've found what is causing the issue. background-position stops working when the background is as big (or bigger) as the frame it contains. This is also why dognose's solution works. It removes the background-size. As proof, I've changed the CSS of the .br-frame and...

Your question if I get it right is not about programming or about math. It is about business analysis :-) You wrote : is clearly selling well. What is your criteria to decide what is WELL? In different situation and business flows there are many parameters. For example if your...

r,formatting,plyr,percentage,crosstab

pt <- percent(c(round(prop.table(tab), 3))) dim(pt) <- dim(tab) dimnames(pt) <- dimnames(tab) This should work. c being used here for its property of turning a table or matrix into a vector. Alternative using sprintf: pt <- sprintf("%0.1f%%", prop.table(tab) * 100) dim(pt) <- dim(tab) dimnames(pt) <- dimnames(tab) If you want the table written...

Have you tried something like: total = total * 1.1 ...

It's probably better to calculate the percentages beforehand: library(dplyr) dfl <- df %>% group_by(group,choice) %>% summarise(n=n()) %>% group_by(group) %>% mutate(perc=100*n/sum(n)) ggplot(dfl, aes(x=group, y=perc, fill=group)) + geom_bar(stat="identity") + ylab("percent") + facet_wrap(~ choice) this gives: Another (and probably better) way of presenting the data is to use facets by group: ggplot(dfl, aes(x=choice,...

Well, you just do : percentage = (num/total)*100; ...

This should do the trick: $(document).ready(function () { var percent = "40%"; $("#meter").css("width", percent); $(".fan-percent").text(percent); }); function addHappiness(){ var currentPercent = $("#meter")[0].style.width.slice(0,-1); newpercent = +currentPercent + 10; $("#meter").css("width", newpercent + "%"); $(".fan-percent").text(newpercent + "%"); } JsFiddle: https://jsfiddle.net/dnyseaen/1/...

excel,pivot-table,percentage,worksheet-function,countif

If your results are in Column A for example, then something like: ="Less than $1 million: "&(COUNTIF(A:A,"Less than $1 million")/COUNTA(A:A))*100&"%" should do you. If you have a header in Row 1 then change COUNTA(A:A) to COUNTA(A:A)-1 based on your example above, this formula would return "Less than $1 million: 62.5%"...

Probably suctrades * totaltrades is still an int. The easiest way will be probably changing your code to: ((double)suctrades) * totaltrades/100 Or suctrades * totaltrades/100.0 To force using double instead of int...

If you check 1/4 you'll get 0, not 0.25. Because 1 and 4 are ints. In [42]: 1/4 Out[42]: 0 In [43]: 1.0/4 Out[43]: 0.25 so (3 + 2 + 1 - 5) = 1 (4 % 2) = 0 (1 / 4) = 0 and the final result will...

php,laravel,laravel-4,eloquent,percentage

Okay, so you have a star based rating system out of 5 stars. I'm going to make a few assumptions/suggestions below. I assume you have a ratings table that literally just stores one row per rating, if not, I'd recommend setting one up. <?php class Rating extends \Eloquent { protected...

jquery,angularjs,scroll,scrollbar,percentage

You should be using $window.pageYOffset and $window.innerHeight Their division will give you a value from 0 to 1 so if you prefer a comparison to a percentage kind of number, just multiply by 100. This should work like you want, more or less (just replace console.log with whatever action you...

python,formatting,decimal,percentage

If you want to show a percentage, you should just use the percent formatter directly: >>> '{:.0%}'.format(S.count('f') / 9) '11%' As others already noted, Python 2 will use integer division if both arguments are integers, so you can just make the constant a float instead: >>> '{:.0%}'.format(S.count('f') / 9.) '11%'...

Then I thought I could just add 15% margin-top or add 15% padding-top (to the parent) to vertically center the p tag in the div... but I find I need to set it to something like 3%.... how come? Because percent margins and paddings (top, right, bottom and left)...

javascript,jquery,offset,percentage

I found the answer for this. helperPos_x = ($('.helper').offset().left / $(window).width() * 100); ...

jquery-ui,percentage,resizable

I ran into this same issue and the chosen solution doesn't work for me because I need this to generalize to any number of columns. Also codenamezero's answer did not deal with the fact that the original question requires that percentages for widths are used. For my case using percentages...

r,graph,plot,categories,percentage

Using these colours intuitively makes me to suggest the ggvis package that uses exactly those two colours (by default although obviously you can change them) to do this: Look at the following example: Data y <- letters[1:10] x <- runif(10) gender <- rep(c('male','female'),5) df <- data.frame(y,x,gender) Solution library(ggvis) df %>%...

javascript,jquery,graphics,highcharts,percentage

try out this tooltip: { formatter: function () { var s = '<b>' + this.x + '</b>'; $.each(this.points, function () { s += '<br/>' + this.series.name + ': ' + this.y *100; }); return s; }, shared: true } sample fiddle :)...

sql,postgresql,aggregate-functions,percentage

Use window functions: SELECT ID, COUNT(*), COUNT(*) / SUM(COUNT(*)) OVER () AS "% OF TOTAL" FROM DATA GROUP BY ID; ...

html,css,width,viewport,percentage

Make the positions relative instead of absolute , then width:100% should work #mainslide { position: relative; left:100% z-index: 1; } #aanbod { position: relative; left: 0px; } .tablestyleorchideeaanbod { width: 100%; padding: 12px; padding-left: 8%; padding-right: 8%; border-bottom-width: 1px; border-top-width: 0px; border-left-width: 0px; border-right-width: 0px; border-style: solid; border-color: #8cca49; }...

javascript,html,percentage,argument-passing

It seems working : HTML : <input type='text' id="pointspossible"/> <input type='text' id="pointsgiven" /> <input type='text' id="pointsperc" disabled/> JavaScript : $(function(){ $('#pointspossible').on('input', function() { calculate(); }); $('#pointsgiven').on('input', function() { calculate(); }); function calculate(){ var pPos = parseInt($('#pointspossible').val()); var pEarned = parseInt($('#pointsgiven').val()); var perc=""; if(isNaN(pPos) || isNaN(pEarned)){ perc=" "; }else{ perc =...

java,string,percentage,uppercase

Try: int uppers = 0; for(char c : s.toCharArray()) { if(Character.isUpperCase(c)) { ++uppers; } } double pct = (uppers * 1D) / (s.length() * 1D) * 100D; if(pct > 60D) { // do somnething } ...

django,templates,translation,percentage,django-i18n

I found a simple solution, maybe even better than the one suggested in Handling percent-sign (%) in Django blocktrans tags {% blocktrans with percent="%" %} This is 100{{ percent }} working! {% endblocktrans %} ...

The length of your circle path is 628.407. So your dasharray and your dashoffset have to match that. You were using a dasharray of 600 and a dashoffset of 547. If you change both to 629. The progress meter will complete. <path d="M200,100 C200,44.771525 155.228475,0 100,0 C44.771525,0 0,44.771525 0,100 C0,155.228475...

ruby-on-rails,ruby,class,ruby-on-rails-4,percentage

number_to_percentage doesn't return a tag. It returns a simple string. If you want to wrap it in a tag with a class, you need to do that manually: <div class="number"><%= number_to_percentage(a.number, precision: 1) %></div> ...

130 / 20 performs integer divison From / Operator (C# Reference) When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2 That's why it always discards the fractional part and it returns 6. That's why your result will be...

This will work: function percentage_check(n) { if(n.toString().match(/^\d+\.?\d?\d?%?$/) && parseFloat(n)<=100 && parseFloat(n)>=0){ return true; } return false; } https://regex101.com/r/gN7pA8/1...

Check out the number_format function (returns a string): number_format($price, 2); Will return the string "12.50" when $price is set to 12.5...

php,regex,string,split,percentage

You could match up until the 3rd occurrence of the percent sign. $str = '51% 20% 19% 6% 3% 2% 2%'; preg_match('/^(?:[^%]*%){3}/', $str, $match); echo $match[0]; //=> "51% 20% 19%" A verbose way would be.. $str = '51% 20% 19% 6% 3% 2% 2%'; $val = explode(' ', $str); echo...

arrays,matlab,percentage,accumarray

This could be one approach: %// make all those non-zero values to zero AprefCORmask = AprefCOR == 1; %// you have done this [OTPCORorder1,~,idx] = unique(OTPCORorder,'stable'); %// Find number of each unique values counts = accumarray(idx,1); %// Find number of ones for each unique value sumVal = accumarray(idx,AprefCORmask); %// find...

Your mistake is assuming that these are just pure, abstract numbers. I assume that counter is an int... so the second version is evaluated as: int tmp = counter / cap; int i = tmp * 100; Now we're dealing with integer arithmetic here - so if counter is in...

javascript,jquery,percentage,pixels

jQuery offset top takes the negative margin into account. It's not only looking at the top value. Here is something you could do: var margin = parseInt($('h1').css("margin-top")) * -1, //positive val of margin offset = margin + $('h1').offset().top; $('h1').css({ top: offset + "px" }); ...

I suggest that you restructure the data. ggplot has some nice charts. #restructure data library(reshape2) data <- melt(test) data$Form <- c("FormA","FormB","FormC") #plot with ggplot2 library(ggplot2) ggplot(data, aes(variable, value)) + geom_bar(stat="identity") + facet_wrap(~ Form) ggplot(data, aes(variable, value)) + geom_point() + facet_wrap(~ Form) ggplot(data, aes(variable, value,colour=Form, group=Form)) + geom_point() ...

If you wish to get the percentage based off the highest number, here is an example with two loops (one to finding the max value and the other for changing actual values): var res = document.getElementById('r'); var myObj = { red: "332", green: "632", yellow: "14", brown: "45", pink: "83",...

In your call, when you do sum(Total) you are using the total value of the group, which when used with Total/sum(Total) simply produces 1 for this data/grouping. You could calculate the total sum from the entire data set by using df$Total in the sum() call. With ddply this would be...

Don't put the COUNT inside the SUM. Try like this: ,CAST(SUM(CASE WHEN mrSTATUS = 'Closed' THEN 1 ELSE 0 END) AS float)/CAST(COUNT(*) AS float) as [Percentage of Tickets Closed] The SUM and COUNT functions will produce integers, which means the division will also result in an integer. CAST them as...

Assuming you won't have an end and start being the same and start<=currentPos<=end var currentPercentile = (currentPos-start)/(end-start); Update if your end and start can be the same value then it can be 100, 0, or unknown since it'd be outside the range, your choice. var currentPercentile = 100; if(end-start >0){...

<?php if ( $h->deal_percentage > 0) { echo '<div class="hot_label"><p>OFF</p><b>' . round($h->deal_percentage) . '%</b></div>'; } ?> ...

html,alignment,fixed,percentage

just reduce width size in #relativeDiv to width:62%; or adjust it

Break statements are missing from your switch(s). Plus you need to type cast the result to float as all the variables are integers. i suggest you use: float perc; perc = (numCorrect/possibleCorrect)*100; ...

postgresql,percentage,psql,window-functions

Try the easiest way, don't use windows functions: SELECT count( Monday )::float / ( count(Monday) + count(Tuesday ) + count(Wednesday ) + count( Thursday ) ) * 100 As Monday_Percent FROM mytable demo: http://sqlfiddle.com/#!12/e295c/3...

ios,audio-streaming,percentage,seek,internet-radio

This isn't possible. These streams are live. There is nothing to seek to because what you haven't heard hasn't happened yet. Even streams that playback music end-to-end are still "live" in the sense that the audio you haven't received hasn't been encoded yet. (Small codec and transit buffers aside, of...

I would use avg(). In some databases: select agentId, avg(rating) as yes_ratio, avg(1 - rating) as no_ratio from temptable t group by agentid; Some databases do integer arithmetic (notably SQL Server), so you want a non-integer numeric. I often do this just by multiplying by 1.0: select agentId, avg(rating*1.0) as...

c#,.net,format,percentage,string.format

Ok thanks, so that's not possible with string.Format() And what do you think of this ? bool hasDecimal = !percentage.Value.ToString("P1", CultureInfo.InvariantCulture).EndsWith(".0 %"); string percentageMask = hasDecimal ? "{0:P1}" : "{0:P0}"; string percentageValue = string.Format(CultureInfo.CurrentCulture, percentageMask, percentage); ...

python,list,distribution,percentage

This can trivially be achieved by setting a slice with a step: def select_elements(seq, perc): """Select a defined percentage of the elements of seq.""" return seq[::int(100.0/perc)] In use: >>> select_elements(range(10), 50) [0, 2, 4, 6, 8] >>> select_elements(range(10), 33) [0, 3, 6, 9] >>> select_elements(range(10), 25) [0, 4, 8] You...

On MDN for padding : Percentages refer to the width of the containing block [source] This means percentage padding is calculated according to the width of the parent element, not the element itself. In your case padding top for #container is calculated according to the width of <body>....

python,math,numpy,dictionary,percentage

If I understand correctly, you want to do first calculate the average percentage within a server. Then you want to modify that average to be representative of the average time across all of the servers within in a given country. So for "BR" you would divide that average by 1...