count

MySQL Count values based on multiple columns

I have two tables: a 'userlist' that has a 'grade' and 'userID' columns, and a 'login' table that records each time a user is logged in. The login table has a 'userID' column that is associated with the 'userID'. This login table has a row inserted into it each time a user is logged in, so if a user logs in three times, three rows will b...

PostgreSQL Update not returning zero count

Hi folks, I tried to update a particular record with same value again and again, but it returns the affected rows value as 1 always. update users set active = 1 where id = 304 1 row(s) affected. again the same query update users set active = 1 where id = 304 1 row(s) affected. but the second update should return 0 row(s) affected...

Mysql count vs mysql SELECT, which one is faster?

If I want to do a check a name, I want to see how many rows/name exists in the "username" column under users table. Lets say thousands ... hundred of thousands, should I use: count(name), count(*) or SELECT username FROM users where username = 'name' Which one is the more appropriate? Or they will give same result in term of speed/...

Optimizing word count

(This is rather hypothetical in nature as of right now, so I don't have too many details to offer.) I have a flat file of random (English) words, one on each line. I need to write an efficient program to count the number of occurrences of each word. The file is big (perhaps about 1GB), but I have plenty of RAM for everything. They're...

SubSonic 2.1 help needed c#

Hello everyone, I got the following setup for my database: Category Table (Fields: CategoryID(PK), Title); Menu Table (Fields: MenuID(PK) CategoryID(FK), Title); Page Table (Fields PageID(PK), MenuID(FK), Title, Content, CreatedOn); Now for one page I want to know how many Pages a particular category holds. I have no clue how to ma...

Trying to Count specific items in QUERY

Hi, I currently am returning a table that looks like this: Country Result ------ ----- Japan sunk Japan sunk USA ok USA ok with country and result being the column names Id like to know how many times japan and sunken show up? So the resulting query I am trying to achieve is: country numSunk ------- ----...

php - counting values from an array

Hi all, I'm trying to count all the values inside an array, I've tried using count() but to no avail, the array values may also have negatives in them, example: Array ( [name] => 1 [phone] => 1 [emailX] => 1 [car] => 0 [finance] => 2 [employed] => 1 [credit] => -5 ) If you count all of them together, the re...

PHP - check if array is inside a string

$comment = 'billie jean is not my lover she is just a girl'; $words = array('jean','lover','jean'); $lin = some_function_name($comment,$words); ($lin=3) I tried substr_count() but it doesn't work on array. Is there a builtin function to do this? Thanks!! ...

MySQL counting most common value

I have a MySQL database where users can list books they've read, want to read etc. I'm trying to write a query to find the most common book that users have listed. My current query is: $result = mysql_query("SELECT title, COUNT(title) AS counttitle FROM books GROUP BY title ORDER BY counttitle DESC LIMIT 1"); echo "<p>The ...

Java count of items in an array (similar to a SQL aggregate function)

I am connecting to a sockets API that is very inflexible. It will return rows such as: NAME, CITY, STATE, JOB, MONTH But will have duplicates because it does not do any aggregation. I need to count the duplicate rows (which would be very easy in SQL, but not, as far as I know, in Java). Example source data: NAME, CITY, STATE, ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? Is there an Apple example, or other tutorial? Thanks, Jordan ...

Select 2 COUNT()'s from MySQL query

I am working on a rankings page for a game and am looking to order the rankings first by wins, and then by losses (in case of people having the same number of wins). The following query works fine in order to make a list in order by wins, but I am not sure how to put losses into this query. SELECT username, COUNT(id) AS wins FROM tb...

COUNT(id) vs. COUNT(*) in MySQL

Is there a difference between the following queries, assuming there is a primary field 'id' in the table (as in speed, etc)? SELECT COUNT(id) FROM table vs. SELECT COUNT(*) FROM table ...

Group by named column

I always forget how to do things like this. I have a database table with birthdates and I want to find out how many people have the same age. I'm trying: SELECT TIMESTAMPDIFF( YEAR, birthdate, CURDATE( ) ) AS age, COUNT( age ) FROM person GROUP BY age but get the error Unknown column 'age' in 'field list' How can I do a gr...

SQL count exposure of life time by age

Hi all (Using SQL Server 2008) I need some help visualizing a solution. Let's say I have the following simple table for members of a pension scheme: [Date of Birth] [Date Joined] [Date Left] 1970/06/1 2003/01/01 2007/03/01 I need to calculate the number of lives in each age group from 2000 to 2009. NOT...

obj-c NSArray count comparison fail

NSArray *test1 = [NSArray arrayWithObjects:@"1",@"2", nil]; NSArray *test2 = [NSArray arrayWithObjects:@"1",@"2", nil]; NSArray *test3 = [NSArray arrayWithObjects:@"1",@"2", nil]; NSLog(@"%d", [test1 count] == [test2 count] == [test3 count]); Will print 0. Why? ...

SQL: count of replica entries in a column

Simplistically I have a table that looks like this: ColA | ColB | -----+------+ EE34 | Woo | ER56 | fro | EE34 | eco | QW34 | Sddg | EE34 | zoo | ER56 | safe | I need a select statement for SQL Server that produces: ColA | Count | -----+-------+ EE34 | 3 | ER56 | 2 | QW34 | 1 | This could be running over a table wit...

JSF 1.2 - Problem with passing page count to bean to create list

I have this select option: <f:verbatim>Pages: </f:verbatim> <h:selectOneMenu id="selectPage" value="#{pageList.selectedPage}"> <f:selectItems value="#{pageList.selectPages}" /> </h:selectOneMenu> And the backing bean (called mybean2) for this is: private int pages; public void getPages(int Pages) { this.pages = Pages; } // ge...

Which command in VBA can count the number of characters in a string variable?

Let's say I have this variable: word = "habit" which command in VBA will allow me to count how many characters are there in this variable (in my case it's 5). Important: the variable "word" contains only one word, no spaces, but may have contain numbers and hyphens. ...

Word count of a string

How to count the words in a document, get the result same as the result of MS OFFICE? ...