count

count (non-blank) lines-of-code in bash

In Bash, how do I count the number of non-blank lines of code in a project? ...

How to efficiently count the number of keys/properties of an object in JavaScript?

What's the fastest way to count the number of keys/properties of an object? It it possible to do this without iterating over the object? i.e. without doing var count = 0; for (k in myobj) if (myobj.hasOwnProperty(k)) count++; Firefox provides a magic __count__ property, but this isn't available in other implementations. ...

Informix SQL Syntax - Nest Count, Sum, Round

Let me apologize in advance for the simplicity of this question (I heard Jeff's podcast and his concern that the quality of the questions will be "dumbed down"), but I'm stuck. I'm using AquaData to hit my Informix DB. There are quirky little nuances between MS SQL and Informix SQL. Anyway, I'm trying to do a simple nested expression ...

Why are Wemf and Google Analytics telling me so different things?

The website works with Wemf and Google Analytics, but they are giving me very different results; WEMF counts 10 - 30 % more page views than Google Analytics... Why can this be? Google Analytics works only with JavaScript enabled, yes - but I don't think that's the reason for this difference. The site which should be counted is a famous ...

SQL Subquery

I have SQL data that looks like this events id name capacity 1 Cooking 10 2 Swimming 20 3 Archery 15 registrants id name 1 Jimmy 2 Billy 3 Sally registrant_event registrant_id event_id 1 3 2 3 3 2 I would like to select all of the fields in 'ev...

Return total number of files within a folder using PHP.

Is there a better/simpler way to find the number of images in a directory and output them to a variable? function dirCount($dir) { $x = 0; while (($file = readdir($dir)) !== false) { if (isImage($file)) {$x = $x + 1} } return $x; } This seems like such a long way of doing this, is there no simpler way? Note: The isImage()...

How to count unique records and get number of these uniques in table using SQL?

Hi, Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this is an example of large internet mall, where there are shops which sell to one customer, so customer can choose more products from each shop and buy it in one basket. However, I am not sure if there is an...

Finding difference in row count of two tables in MySQL

I have two tables, one stores the products and quantity we have bought, the other stores the sells. The current stock is therefore the sum of all the quantity columns in the bought table minus the number of rows in the sells table. How can this be expressed in MySQL. Remember that there are many different products. EDIT: To make it hard...

How do you count the rows in a SQL query which alredy used count, group by, and having before?

For example, using the answer for this question: http://stackoverflow.com/questions/152024/how-to-select-all-users-who-made-more-than-10-submissions "How to select all users who made more than 10 submissions." select userId from submission group by userId having count(submissionGuid) > 10 Let's say now I want to know many rows th...

Count work days between two dates in T-SQL

How can I calculate the number of work days between two dates in SQL Server? Monday to Friday and it must be T-SQL. ...

Can I get the rowcount before executing a stored procedure?

I have some complex stored procedures that may return many thousands of rows, and take a long time to complete. Is there any way to find out how many rows are going to be returned before the query executes and fetches the data? This is with Visual Studio 2005, a Winforms application and SQL Server 2005. ...

SQL: Complex Deletion help

I basically created some tables to play around with: I have Two main tables, and a Many-Many join table. Here is the DDL: (I am using HSQLDB) CREATE TABLE PERSON ( PERSON_ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, NAME VARCHAR(50), MAIN_PERSON_ID INTEGER ) CREATE TABLE JOB ( JOB_ID INTEGER GENERATED BY DEF...

What's the best way to determine the total number of words of a file in Java?

What is the best way to find the total number of words in a text file in Java? I'm thinking Perl is the best on finding things such as this. If this is true then calling a Perl function from within Java would be the best? What would you have done in condition such as this? Any better ideas? ...

Where should I do the rowcount when checking for existence: sql or php?

In the case when I want to check, if a certain entry in the database exists I have two options. I can create an sql query using COUNT() and then check, if the result is >0... ...or I can just retrieve the record(s) and then count the number of rows in the returned rowset. For example with $result->num_rows; What's better/faster? in my...

Summary query from several fields in SQL

Data table structure is: id1,id2,id3,id4,... (some other fields). I want to create summary query to find out how many times some ID value is used in every column. Data 1,2,3,4,2008 2,3,5,1,2008 1,3,2,5,2007 1,2,3,6,2007 3,1,2,5,2007 For value 1, the result should be 1,0,0,1,2008 2,1,0,0,2007 How to accomplish this with one query (in M...

Count rows in an SQL table in O(1)

I understand the best way to count the number of rows in an SQL table is count(*) (or equivalently count(PrimaryKey)). Is this O(1)? If not, why not? Why not just implement a counter and return it for this specific query? Is it because this query is not a common use case? If the answers vary according to SQL engine, I'd like to hear...

Count occurrences of a word in a row in MySQL

I'm making a search function for my website, which finds relevant results from a database. I'm looking for a way to count occurrences of a word, but I need to ensure that there are word boundaries on both sides of the word ( so I don't end up with "triple" when I want "rip"). Does anyone have any ideas? People have misunderstood my ...

How to sort a list of objects in Python, based on an attribute of the objects?

I've got a list of Python objects that I'd like to sort by an attribute of the objects themselves. The list looks like: >>> ut [<Tag: 128>, <Tag: 2008>, <Tag: <>, <Tag: actionscript>, <Tag: addresses>, <Tag: aes>, <Tag: ajax> ...] Each object has a count: >>> ut[1].count 1L I need to sort the list by number of counts descending. ...

How should I count the number of occurrences of a character at the beginning of a string in PHP

The best that I have been able to come up with is: strlen(preg_replace('/^([\\*]*)\s(.+)/',"$1",$line)); ^^That seems to give the length of the string.^^ edit: I think that I should clarify that the character that I am trying to find is '*' ...

sql statistics io scan count explanation

Hi, Simple question, but I haven't found a good explanation on google. When using Set Statistics IO ON, the logical reads and scan count is provided in the message window of management studio. If I have: tblExample, scan count 5, logical reads 20 What does scan count signify? ...