count

Count Lines of Code from Java class

What would be the best way to count lines of code from Java classes excluding comments and blank lines. ...

mysql slow COUNT()

Hi all, I'm having some difficulties with a query: SELECT d.*, (SELECT COUNT(id) FROM downloads WHERE category = d.category) AS count FROM downloads d GROUP BY d.category ORDER BY count DESC So, I'm trying to get the total downloadcount of each category but this query hangs each time I run it. The downloads table has +- 2...

Help with Oracle SQL Count function! =)

Hi guys.. The question I'm struggling with is this: I have a list of helicopter names in different charters and I need to find out WHICH helicopter has the least amount of charters booked. Once I find that out I need to ONLY display the one that has the least. I so far have this: SELECT Helicopter_Name , COUNT (Distinct Chart...

Count the number of times a string appears within a string...

I simply have a string that looks something like this: "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false" All I want to do is to count how many times the string "true" appears in that string. I'm feeling like the answer is something like String.CountAllTheTimesThisStringAppearsInThatString() but for some reason I jus...

self join- how to use the aggregate functions

self join- how to use the aggregate functions select a.tablename, b.TableName,b.UserName from Employee a inner join Employee b on a.ColumnValue=b.ColumnValue and and a.TableName <> b.TableName and a.UserName=b.UserName and also to check whether the same user has count of records i.e Employee a = count of records of Employee b...

SQL query to get lowest 2 values of a counted query selection (using db2)?

Hi, Imagine I already have a query that returns the following: Col1 | Col2 ------------ A | 2 B | 3 C | 3 D | 4 E | 8 ... Say I used something like this: select Col1, count ( * ) as Col2 \ from ... where ... order by Col2 \ group by Col1 \ So now, all I want to select are (Col1, Col2) such that it r...

Count Records in Listing View

I have these two models: class CommonVehicle(models.Model): year = models.ForeignKey(Year) series = models.ForeignKey(Series) engine = models.ForeignKey(Engine) body_style = models.ForeignKey(BodyStyle) ... class Vehicle(models.Model): objects = VehicleManager() stock_number = models.CharField(max_length=6, bla...

Select 2 Rows from Table when COUNT of another table

Here is the code that I currently have: SELECT `A`.* FROM `A` LEFT JOIN `B` ON `A`.`A_id` = `B`.`value_1` WHERE `B`.`value_2` IS NULL AND `B`.`userid` IS NULL ORDER BY RAND() LIMIT 2 What it currently is supposed to do is select 2 rows from A when the 2 rows A_id being selected are not in value_1 or value_2 in B....

Mathematica: get number of arguments passed to a function?

How do I get the number of arguments passed to a function, such as Plus[2,3,4,5] has 4 arguments passed to it. I was thinking it may involve the use of the function Length and getting the arguments into a list. The intention is to iterate an operation based on the number of arguments for a function. There is probably a simple solution or...

simple jquery second counter

What is the simplest way to increase a variable by 1 every second? ...

Getting the count of rows in a Java resultset

Hello Does anyone know a better way of getting the number of rows in a Java resultset returned from a MySQL database? I'm currently using this: public static int getResultSetRowCount(ResultSet resultSet) { int size = 0; try { resultSet.last(); size = resultSet.getRow(); resultSet.beforeFirst(); } ...

Finding process count in Linux via command line

I was looking for the best way to find the number of running processes with the same name via the command line in Linux. For example if I wanted to find the number of bash processes running and get "5". Currently I have a script that does a 'pidof ' and then does a count on the tokenized string. This works fine but I was wondering if the...

Connect to a MySQL database and count the number of rows.

Hi there! I need to connect to a MySQL database and then show the number of rows. This is what I've got so far; <?php include "connect.php"; db_connect(); $result = mysql_query("SELECT * FROM hacker"); $num_rows = mysql_num_rows($result); echo $num_rows; ?> When I use that code I end up with this error; Warning: mysq...

Count items in Dictionary that begin with certain text

I have a dictionary that looks something like this test1 : 123 test2 : 456 another1 : abc test3 : 789 another2 : def How can I get a count of all the items that begin with "test" in c# framework 3.5? ...

Select nth percentile from MySQL

I have a simple table of data, and I'd like to select the row that's at about the 40th percentile from the query. I can do this right now by first querying to find the number of rows and then running another query that sorts and selects the nth row: select count(*) as `total` from mydata; which may return something like 93, 93*0.4 = ...

Help getting retweets with Python Twitter Tools

I'm using this library: http://mike.verdone.ca/twitter/ to access Twitter. The author states, "Its methods are directly bound to the Twitter API's URLs. For instance twitter.statuses.friends_timeline() will always hit the URL http://twitter.com/statuses/friends_timeline.json. Always." If this is the case, would it even be possible to hit...

IN R counting hierarchical data

I have a list of counties in each state that received nonattainment status in years 1995-2005. I want to know how many counties in each state each year that received this status. If my data is formatted like this, State1 Country1 YR1 Yr2 Yr3 Yr4... State1 Country2 YR1 Yr2 Yr3 Yr4 State2 County1 Yr1 Yr2..... Each year variable coul...

SQL count returning one value (and not the total).

Hi all. I need to get the nid "alone" in this query. SELECT count(nid) as total,nid FROM bird_countries b group by nid order by total asc` Basically I need this to do something like update table set field=1 where id in (the other query); Right now, I'm getting the total of nid's and the nid, but can't find how to just get the nid ...

C++ counting execution time eror

Hi, I'm trying to count the execution of function in my code (that takes over an hour), and I'm using clock(), but I'm getting some errors, since the time calculated is negative. I'm doing like this: long double time; clock_t start, t_end; t_start = clock(); algorithm->execute(); t_end = clock(); time = ((long double) t_end - t_start)...

JOIN on another table after GROUP BY and COUNT

I'm trying to make sense of the right way to use JOIN, COUNT(*), and GROUP BY to do a pretty simple query. I've actually gotten it to work (see below) but from what I've read, I'm using an extra GROUP BY that I shouldn't be. (Note: The problem below isn't my actual problem (which deals with more complicated tables), but I've tried to c...