counting

SQL - sub count

Hi I've got some SQL ... SELECT AdviceNo, Registration FROM tblSalesDetail that produces something like ... ADV00001, ABC123 ADV00001, CDE564 ADV00002, FGE432 ADV00003, HUY789 ADV00003, MJS532 ADV00003, JFY428 Can anyone tell me how I'd adjust it to see the following please? ADV00001, ABC123, 1 ADV00001, CDE564, 2 ADV00...

python histogram one-liner

there are many ways, how to code histogram in Python. by histogram, i mean function, counting objects in an interable, resulting in the count table (i.e. dict). e.g.: >>> L = 'abracadabra' >>> histogram(L) {'a': 5, 'b': 2, 'c': 1, 'd': 1, 'r': 2} it can be written like this: def histogram(L): d = {} for x in L: if x ...

Count how many times functions echo a statement.

I have a function that calls two other functions: class myClass{ function myFunc(){ for($i=0;$i<500;$i++){ $this->func1(); $this->func2(); } } function func1(){ // Does some stuff // echos statements, and can vary the amount of echoed statements while($so...

Counting tags inside a iframe using jquery

iframe src is like this:-<iframe src="http://mysite.com/testing.php?id=7632762"&gt;&lt;/iframe&gt; and the content is dynamic.How to find out number of <div> or <li> or <p> tags inside a iframe by using javascript on server side or client side ? -Thank you ...

Counting distinct items in XSLT

I have XML like this: <assessment> <variables> <variable> <attributes> <variable_name value="FRED"/> </attributes> </variable> </variables> <variables> <variable> <attributes> <variable_name value="MORTIMER"/> </attributes> </variable> </variables> <variables> <variable> <attributes> <variable_n...

Counting distinct items in XSLT independent of depth

If I run the following XSLT code: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; <xsl:output method="text"/> <xsl:key name="kValueByVal" match="variable_name/@value" use="."/> <xsl:template match="assessment"> <xsl:for-each select=" /*/*/variable/attributes/variable_name/@value ...

select count(*) vs keep a counter

Assuming indexes are put in place, and absolute-count-accuracy is not necessary (it's okay to be off by one or two), is it okay to use: Option A select count(*) from Table where Property = @Property vs Option B update PropertyCounters SET PropertyCount = PropertyCount + 1 where Property = @Property then doing: select ...

keeping count of new items

here is my scenario I have a nested sortable tree simplified looks like this <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title></title> </head> <body> <ul> <li id="item_123" name="123"> <fieldset class="additem"> <input type="text" name="title" value=""> </fieldset> ...

counting data and grouping by week in mysql

this is my DB table: CREATE TABLE IF NOT EXISTS `inspection_report` ( `Inspection_datetime` datetime NOT NULL, `Line` char(5) NOT NULL, `S` int(11) NOT NULL, `A` int(11) NOT NULL, `B` int(11) NOT NULL, `C` int(11) NOT NULL, INSERT INTO `inspection_report` (`Inspection_datetime`,`Line`,`S`, `A`, `B`, `C`) VALU...

character count minus HTML characters C#

I'm trying to figure out a way to count the number of characters in a string, truncate the string, then returns it. However, I need this function to NOT count HTML tags. The problem is that if it counts HTML tags, then if the truncate point is in the middle of a tag, then the page will appear broken. This is what I have so far... publi...

NSSortDescriptor can't count numbers at all..

With this NSSortDescriptor *lessonDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lesson" ascending:YES]; [resultArray sortUsingDescriptors:[NSArray arrayWithObject:lessonDescriptor]]; it's sorting the "lesson"-objects to ( { lesson = 9; subject = bg; }, { lesson = 8; subject = bg; }, { lesso...

Is there a limit to the base to which numbers can be associated to?

This may be very convoluted and twisted idea. Got it while learning some JavaScript. It piqued my mind. Hoping there may be someone else who would have thought about it before or might enlighten me :-) var n = 17; binary_string = n.toString(2); // Evaluates to "10001" octal_string = "0" + n.toString(8); // Evaluates to "021" h...