count

Multiple counts within a single SQL query

I'm trying to get the count of documents within 4 specific sections using the following code: SELECT category.id , category.title , count(ts1.section_id) AS doc1 , count(ts2.section_id) AS doc2 , count(ts3.section_id) AS doc3 , count(ts4.section_id) AS doc4 FROM category LEFT JOIN category_link_section A...

Ruby, Count syllables

Hey, I am using ruby to calculate the Gunning Fog Index of some content that I have, I can successfully implement the algorithm described here: Gunning Fog Index I am using the below method to count the number of syllables in each word: Tokenizer = /([aeiouy]{1,3})/ def count_syllables(word) len = 0 if word[-3..-1] ==...

Conditional Count on a field

Hello, If I had a table like this: jobId, jobName, Priority Whereby Priority can be an integer between 1 to 5. Since I would need this query for generating a chart on report, I would need to display the jobid, jobname and 5 fields called Priority1, Priority2, Priority3, Priority4. Priority5. Priority1 should count the amount of r...

To count a character in files by Find/Xargs/Sed

How can you count the number of the character < in your files? I am trying to count the number of the character "<" in my files, similarly as in Vim by %s/<//gn I run find * -type f | xargs sed 's/<//gn' I get sed: -e expression #1, char 7: unknown option to `s' This error suggests me that Vim's :s -mode is not like SED. ...

count from several multidimensional arrays

hi all, i have foreach, which generate following arrays: ==== array 1 ==== array 0 => array 'tag' => string 'daf' (length=3) 1 => array 'tag' => string 'daa' (length=3) 2 => array 'tag' => string 'daf' (length=3) 3 => array 'tag' => string 'daaa' (length=4) 4 => array 'ta...

Help to write SQL query

Hi all, I have 2 tables as follows: tags: id version name tag_links: id version tag_id (foreign key to tags.id) I need to write an SQL statement that returns how many times each tag_id occurs in tag_links table. For example: tags: id version name -- ------- ------ 1 1 sport 2 ...

Get count of distinct groups in a single SQL query in Firebird 1.5?

I ran across the following in a stored procedure: for select 1 from scan_queue where ( date_time_locked is null ) and ( scan_seqno >= :varMinScanSeqno ) and ( scan_seqno <= :varMaxScanSeqno ) group by loan_id, collateral_id, insurance_id into varNotUsed do varItemsToScan = varItemsToS...

Countdown Timer in Cocoa

Hi Everyone: I am wondering if there is some way that I can create a timer that countdown from a given time. For example, say I want this timer to last an hour. There will be a NSTextField that will show the time remaining (ex. 25 minutes), and will auto update every minute to the new value. And then, when an hour is finally passed, ...

PHP: Count an stdClass object

Hi guys, I have a stdClass object created from json_decode that won't return the right number when I run the count($obj) function. The object has 30 properties, but the return on the count() function is say 1. Any ideas? Below is an example of one of the objects. (I'm requesting the daily trend information from Twitter). If this ob...

PHP count amount in array with a given value

Say I have an array like this: $array = array('', '', 'other', '', 'other'); How can I count the number with a given value (in the example blank)? And do it efficiently? (for about a dozen arrays with hundreds of elements each) This example times out (over 30 sec): function without($array) { $counter = 0; for($i = 0, $e = co...

MySQL count row

hi all, how can I count row based on its contents? assumed I have table like this [table a] ID_COMPANY | NAME ----------------------------- A1 | COMPANY A [table b] ID_COMPANY | USER | TYPE -------------------------------------- A1 | USER A | MANAGER A1 | USER B | DEP...

Count number of files with certain extension in Python

I am fairly new to Python and I am trying to figure out the most efficient way to count the number of .TIF files in a particular sub-directory. Doing some searching, I found one example (I have not tested), which claimed to count all of the files in a directory: file_count = sum((len(f) for _, _, f in os.walk(myPath))) This is fine, ...

Count of consecutive not null values

The count should be 3 and 1 in the following query. The count should be of the points earned consecutively. So once the user fails to earn any points, the count restarts. mysql> select name, count(*) from sortest group by name, (points = 0) OR (points is NULL) having name= 'john'; +------+----------+ | name | count(*) | +------+-------...

SQL question about counting...

I want to make a query so that I can grab only Locations that have at least 50 Places. I have a table of Locations: Id, City, Country 1, Austin, USA 2, Paris, France And a table of Places connected to Locations by Location_id Id, Name, Details, Location_id 1, The Zoo, blah, 2 2, Big Park, blah, 2 I can join them like so: SELECT p...

Mysql - store a count using a column

Hello, I might have missed something about MySQL. I'm trying to find a way to store a "count" in a column. It has to be dynamically updated without any manual update. I don't want to add or remove 1 to the count any time the member creates or delete a content. The field in contentcount must automatically be a count of every content ow...

Speeding up row counting in MySQL

Suppose, for illustrative purposes, you are running a library using a simple MySQL "books" table with three columns: (id, title, status) id is the primary key title is the title of the book status could be an enum describing the book's current state (e.g. AVAILABLE, CHECKEDOUT, PROCESSING, MISSING) A simple query to report how many...

IndexOutOfRangeException (C#) on OleDBDataReader with SQL Count Function

Good afternoon, I'm having a problem with a section of code I'm working on that checks to see if a dataitem of the same name already exists in a database. The following code throws up an IndexOutOfRangeException static int checkExists(String checkIf) { String connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source...

SQL Distinct Count with an exception

I'm trying to count how many distinct value of FLOOR there is but I don't want the value "B" to count towards the total. Here is my current code. It counts how many distinct floors there is but it includes the FLOOR "B" when there is one. SELECT COUNT(DISTINCT FLOOR) as NB_FLOORS FROM TABLE_ID The table looks something like this : ...

MySQL Selecting count

I have two tables: codes_tags and popular_tags. codes_tags CREATE TABLE `codes_tags` ( `code_id` int(11) unsigned NOT NULL, `tag_id` int(11) unsigned NOT NULL, KEY `sourcecode_id` (`code_id`), KEY `tag_id` (`tag_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 popular_tags CREATE TABLE `popular_tags` ( `id` int(10) unsigned DEFAULT NU...

Count function in HQL causing null results?

I have the following HQL query that is attempting to return 2 object instances as well as an aggregate count based upon a 3rd object instance. SELECT client, clientCampaign, count( formData ) FROM FormData as formData JOIN formData.deliveryResults as deliveryResults JOIN formData.leadForm as leadForm JOIN leadForm.campaignForms a...