Questions tagged [count]

Count refers to the number of objects in a collection. It's also a commonly-used SQL function that counts the number of rows.

Many programming languages offer some sort of count, length or size fields and/or methods for arrays and collections, e.g. PHP's count($array) or Java's array.length.

COUNT() is also commonly-used SQL function that counts the number of rows in a table. It is an ANSI SQL aggregate function that returns the number of times the argument is encountered per group (or if no non-aggregate columns, per query). Commonly, the argument is specified as * - ie COUNT(*) - simply counting the rows. It can be used to count distinct values of a column like this: COUNT(DISTINCT MY_COLUMN)

Reference

See also:

21460 questions
3
votes
2 answers

Discrepancies between “Mock” Database and “Real” database behaviours

We use C# and Linq2SQL with a MS SQL Server Database. We have a mockdatacontext to carry out some unit testing. When testing we have discovered two different behaviours depending on whether the "real" or "mock" database is used. Scenario 1: Real…
user96610
  • 31
  • 5
3
votes
5 answers

PHP - MySQL Search database table return result with percentage match

On my site I allow the users to select what they like or have interest in. This is done using a pre-defined drop down menu, so every time the user logs into the site they get a list of users that have the same interest as them. This is done by…
TheDeveloper
  • 890
  • 1
  • 15
  • 37
3
votes
1 answer

SQL, trying to find which rows have multiple entries

I work for a school system as a data guy, and in my latest report that I need to send to the state I need to send some data about students taking tests. Easy enough. The problem arises from this fact: when teachers or administrators entered data…
Corran Horn
  • 161
  • 1
  • 10
3
votes
3 answers

Facebook Graph API and FQL like count on photo's both incorrect?

Hey all, I've made a facebook application for a contest, which allows users to upload their photo. Once uploaded, the photo gets posted to a dedicated album on their profile. Once the photo is there, the users should collect as many likes as…
3
votes
2 answers

How to find the top 10 most popular values in a comma separated list with PHP & MYSQL

I am new to all of this and I have Googled and searched on here, but to no avail. Using google and some of the responses here, I've managed to solve a separate problem, but this is what I'm really interested in and am wondering if this is even…
Jay Rogers
  • 31
  • 1
3
votes
2 answers

tsql distinct having count

I am using SSMS 2008 and am trying to select count of consumers who are part of two different events. Probably this is a simple query, but it is currently not returning expected count. Here is my T-SQL code which better explains what I…
salvationishere
  • 3,461
  • 29
  • 104
  • 143
3
votes
1 answer

T-SQL Count question

I have the following table that I need to summarize ID A B C D E F G ---------------------------------- 1-100 1 2 1 1 1 1 1 1-201 1 2 1 2 2 2 2 1-322 1 1 1 1 2 2 1 2-155 1 1 2 1 1 …
user918967
  • 2,049
  • 4
  • 28
  • 43
3
votes
3 answers

Transform long data into wide using frequency

I would like to know a practical way to transform dat in the table below dat <- data.frame('city' = c('A','A','B','C','A','B','B','C','C','C'), 'color' = c('red', 'green', 'blue', 'red', 'green', 'blue', 'green', 'blue', 'red',…
3
votes
3 answers

Rails, data structure and performance

Let's say I have a rails app with 3 tables, one for questions, one for options (possible answers to this question), and one for votes. Currently, when requesting the statistics on a given question, I have to make a SQL query for each option which…
Emmanuel
  • 254
  • 3
  • 11
3
votes
4 answers

how can i count chars from word which in the array?

i have an array ["academy"] and i need count chars from the string in the array. output: a:2 c:1 d:1 e:1 m:1 y:1 like this i tried two for loops function sumChar(arr){ let alph="abcdefghijklmnopqrstuvxyz"; let count=0; for (const…
3
votes
2 answers

Count the range of each value in Python

I have dataset of student's scores for each subject. StuID Subject Scores 1 Math 90 1 Geo 80 2 Math 70 2 Geo 60 3 Math 50 3 Geo 90 Now I want to count the range of scores for each…
3
votes
1 answer

LINQ to count occurrences

I have the following query which works great: string[] Words = {"search","query","example"}; ... Snip ... var Results = ( from a in q from w in Words where ( a.Title.ToLower().Contains(w) ||…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
3
votes
1 answer

How to count new users by min date without using a subquery?

I have an event table in which each user has several dates registered. The minimum date for each user would be the join_date for each user. I need to do a count for each user for each min date (join_date). I have achieved what I intend with the…
3
votes
3 answers

How to count the number of words in a paragraph and exclude some words (from a file)?

I've just started to learn Python so my question might be a bit silly. I'm trying to create a program that would: - import a text file (got it) - count the total number of words (got it), - count the number of words in a specific paragraph,…
epo3
  • 2,991
  • 2
  • 33
  • 60
3
votes
2 answers

SQL counting rows having different values

I have a table with values (field valore): CREATE TABLE values ( questionario_id INT(10) UNSIGNED NOT NULL, insegnamento_id INT(11) NOT NULL, domanda_id TINYINT(3) UNSIGNED NOT NULL, valore TINYINT(3) UNSIGNED NOT NULL COMMENT…
vulkanino
  • 9,074
  • 7
  • 44
  • 71
1 2 3
99
100