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
4
votes
4 answers

SQL - Column count doesn't match value count at row 1

I am trying to put this into the database. All rows are correct. Each row is also String/Text, except for "Id" which is an auto-incrementing Int value. I am getting an unexpected error, however, saying Column count doesn't match value count at row…
Anonymous
  • 553
  • 5
  • 17
  • 41
4
votes
5 answers

SQL - Counting only one table's entries in joint query

This seems like a regular thing to do, but I can't seem to find how to do it. I have a join query SELECT a.nom_batim, COUNT(b.maxten) AS NumFaulty FROM tblTrials AS b, tblRooms AS a WHERE b.batiment = a.batiment AND b.maxten > 10 GROUP BY…
StuckAtWork
  • 1,613
  • 7
  • 23
  • 37
4
votes
3 answers

MySQL count rows include zero (so close to what I want!)

I know I'm close and it is KILLING me. Need a fresh set of eyes here... SELECT first_name, COUNT(*) FROM (SELECT first_name, job_status FROM typesetting LEFT JOIN employees ON typesetting.employees_id = employees.id LEFT JOIN job_status ON…
Matt
  • 143
  • 1
  • 2
  • 8
4
votes
3 answers

XPath 1.0 check count

I have the following XML document : Snow Crash Neal Stephenson
URL87
  • 10,667
  • 35
  • 107
  • 174
4
votes
3 answers

SQL how to sum events in one hour between two dates and show it in one row

I am developing a report with C# and SQL server 2005, I have to only show how many hit we got in each hour. the table is very huge. output should look like this: Row# | Date | Time | Hit Count ----------------------------- 1 |…
Pouria
  • 37
  • 4
4
votes
1 answer

Pad counter with leading 0 up to 9, then remove leading zero with php

Trrying to pad with leading 0's up to 9, then remove. 01, 02, 03, 04, 05, 06, 07, 08, 09 - 10, 11, 12, 14 So far I have this:
jrutter
  • 3,173
  • 9
  • 42
  • 51
4
votes
2 answers

COUNT() returning incorrect number of rows

I am using the MySQL COUNT() method to find out how many rows in two tables have the uid of u.id. To do so, I am using the method below: SELECT u.id, u.first_name, u.last_name, u.email, u.username, COUNT( q.uid ) AS `q_count`, COUNT( a.uid ) AS…
max_
  • 24,076
  • 39
  • 122
  • 211
4
votes
2 answers

How to get count of records added since the start of the current month

I am building a webservice using php & mysql, and would like to limit requests from each apikey to (x) amount within (y) time. To achieve this, i count the records added to the the log from each apikey within a period using a sql statement like…
Graham
  • 318
  • 1
  • 16
4
votes
1 answer

MySQL - ranking by count() and GROUP BY

I've got my mysql table posts, where all posts of my forum are stored. It's like this: id uid thread post title text time (int) (int) (varchar) (int) (varchar) (text) (int) Now I want to show the rank…
ninov
  • 629
  • 1
  • 6
  • 17
4
votes
4 answers

Count images in a directory

I want to count how many image are in a directory. I have a copy of some code from internet which can detect the total file inside a directory. import java.io.*; public class CountFilesInDirectory { public static void main(String[] args) { …
Eric
  • 401
  • 4
  • 13
  • 21
4
votes
2 answers

How to count lists inside another list List>>

Now this is example list : List>> dblWordFreqByCluster = new List>>(); What i want is getting the list count at this main list (dblWordFreqByCluster). Which means getting…
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
3
votes
2 answers

Count SQL in MS Access

I have a table called [Review Results] that looks somewhat like the following: [Reviewed By]....[Review Date]....[Corrective…
JT2013
  • 643
  • 6
  • 25
  • 46
3
votes
2 answers

MYSQL select query using count (*)

i have a problem concerning a select query in MYSQL i have two different tables and i want to obtain a certain result i used COUNT method which gave me only the results (>=1) But in reality , i want to use all counts with zero included how to do…
holy
  • 632
  • 2
  • 9
  • 18
3
votes
1 answer

Access 2003 VBA / Sql Update TableA on count condition also in TableA

I'm very new to Sql, and having trouble wrapping my brain around the syntax. I have a table PM (with Fields Acct, Amt, Action, Reason), and I need to update a few fields in the table wherever count(Acct)>1, and the Amt is the same. Specifically,…
graidan
  • 151
  • 2
  • 11
3
votes
1 answer

Sort multidimensional array (PHP) - date complications and counting

I have the following output of an array using PHP. I need to do two things... First, I need to sort the array so it prints by the most recent date. I can't use a simple sort, because the date is outputted in the format mm/dd/yyyy (and not a regular…
DJG
  • 31
  • 2