FAQ Database Discussion Community


Count data per day in a specific month in Postgresql

postgresql,count,each
I have a table with a create date called created_at and a delete date called delete_at for each record. If the record was deleted, the field save that date; it's a logic delete. I need to count the active records in a specific month. To understand what is an active...

SQL Several Count

mysql,sql,if-statement,count,conditional-statements
First sorry if my english is bad, it's not my native language. I have two tables (A and B) with the following columns: A: PRENUMERO (ID), DATA, ARMAZEM, TIPO and B: Autoreg (ID), PRENUMERO, PRODUTO I want a result like: *CountA, CountB, CountC, DATE * CountA is when PRODUTO is...

excel count/sum stop count/sum match?

excel,count,sum,match,sumifs
I have tried to see if this question has been asked before, but I can't seem to find an answer. I have a column of cells (>3000 rows), with either a value of 1 or 0 (call this column A). The value will depend on the value in column B...

COUNTA in current row in an array formula (Google Sheets)

arrays,excel,count,google-spreadsheet,row
I have a Google sheet with fixed number of columns and dynamic rows. I like to use countA to count fields with a value (non-blank) in the current row. I found a formula here but don't understand it, neither can get it to work. ArrayFormula(MMULT( LEN(A1:E)>0 ; TRANSPOSE(SIGN(COLUMN(A1:E1))))) Sheet gives...

Count Distinct Number of Email Addresses in the Results of a Query in MS Access

ms-access,count,distinct
I have a query in MS Access to return multiple columns from multiple tables for a user-specified period of time. This is for a training registration database, and often times, people take multiple classes during a given time period. I need to get a count of the distinct number of...

Add container DIVs around sections in loop

php,wordpress,for-loop,count
I have piece of code below which nearly does what i ned it to do, except I need to modify it so that it adds container DIVs around each set of items within each row. The third snippet of code below shows the output i'm after. I've added around the...

How to achieve MySQL Query combining multiple COUNT() and GROUP BY

mysql,sql,select,count,group
So I have this type of data: id date user_id result 1 2015-05-04 1 win 2 2015-05-06 1 loss 3 2015-05-09 2 loss 4 2015-05-10 2 win 5 2015-05-16 1 win I need to get the top 4 users sorted by most wins. But I also need to get the...

PHP - Count how many days ago

php,mysql,date,time,count
In my database I have a bunch of Last Login dates for my users. They are written like this: Last Login: Apr 08 2015, 22:53:49 CEST And: Last Login: Apr 08 2015, 22:53:49 CET So both CEST and CET at the end can occur. What I'd like to do is...

Show All and Count Duplicates MySQL

mysql,count,group-by
I have this table: id name 1 AAA 2 BBB 3 BBB 4 BBB 5 AAA 6 CCC How can I get this? id name count 1 AAA 2 2 BBB 3 3 BBB 3 4 BBB 3 5 AAA 2 6 CCC 1 I want to count duplicates(name), getting...

Continual counter regardless of page refresh

javascript,php,jquery,html,count
I have this piece of jQuery that currently increments a number by one every 5 seconds. The problem I have is that its client side, therefore it resets every time you refresh the page. Instead I'd like the counter to continue even if you are away from the site and...

MySQL count rows with same values

mysql,count
i have been searching but i didnt find what i was looking for. This is what i have: SELECT user_email, post_type FROM `wp_users` INNER JOIN `wp_posts` ON wp_users.id = wp_posts.post_author WHERE post_type LIKE '%topic%' OR post_type LIKE '%reply% it bring what i needed: I needed a query that shows me...

Return rows where a field has a specified count

sql,count
I have a table (DF) +----+------+-----+ | ID | PT | AVG | +----+------+-----+ | A | 1.00 | 2.5 | | A | 2.00 | 3.5 | | B | 1.00 | 2.8 | | B | 2.00 | 2.6 | | B | 3.00 | 3.9 | +----+------+-----+...

Count multiple columns mysql

mysql,sql,count
I am having hard time writing the query that counts occurrence of specific value in multiple columns. I cannot change the structure of db. I know I can do this using multiple queries and union at the end, but I was wondering is there any smarter solution. Here is an...

Wrong day count between two date

c#,datetime,count
var datetime1 = DateTime.Now; var datetime2 = DateTime.Now.AddHours(5); Console.WriteLine((datetime2-datetime1).TotalDays); datetime1 value is 11:30 PM datetime2 value is a date time value plus more 5 hours. The console output must be 2. But the result is 0.2xxxxxxxxxx. I thinks above code calculate days count base on hour of two date. Not...

How to get count from another table (zero when no data) using single query in mysql?

php,mysql,count
I have two tables - 'Offered' and 'joined'. I need count of 'offered_id' from joined table and zero when not found. My tables and output required is below. How can I achieve this using single query in mysql ? TABLE : OFFERED =============== offered_id data ----------- ---- 1 aaaa 2...

Record count after distinct

sql,oracle,count,distinct
I am using following query for the pagination SELECT * FROM ( SELECT a.*, rownum row_num FROM ( select distinct field1, field2, ... COUNT(*) OVER () RESULT_COUNT from table1 where condition1 order by someField desc )a WHERE rownum < :maxRow )WHERE row_num > = :minRow; I am getting result_count=294 (which...

Count Table Record Value and Assign Count Value as Variable in PHP mySQL

php,html,sql,count
I have a database with area details like state name, district, city, area size, ... Now I would like to count a districts value from state name and assign that value to some variable for showing html page. Example: The tamil nadu state includes total of 30 districts. Query for...

Mysql nested count

mysql,count,aggregate-functions
I have 3 tables connected to each other booking > bid (booking_id) > bid_participants (bid_id) so when a booking is created, it will be blasted and received to more than 0 person or not received at all what i am trying to achieve is to count the booking if is...

New Column with query result in SQL Server

sql,sql-server,count,apply
I need add new column with query result. I have this Query: SELECT DISTINCT Arrival , Flight , TotalPax.SumPassengers , TotalPaxLocal.SumLocalPassengers , STD , STA --, PassengerID --, Departure --, JourneyNumber --, SegmentNumber --, LegNumber --, InventoryLegKey --, RecordLocator FROM #TempLocalOrg tmp CROSS APPLY ( SELECT COUNT(1) AS SumPassengers FROM...

How to change the character count result of a PHP query?

php,count,char,hide
I have created or implemented this character limiter which is common on many websites, in my case I set the limit to be 200 characters at most to be shown followed by an ellipsis. $str = $row[1]; $count = strlen($str); if($count<200){ $post = $row[1]; }else{ $end = $count-200; $mod =...

Multiple joins with ordered by count ignores where conditions

mysql,count,where
I am trying to only get rows from video_index that belongs to a specific category from category_video_rel and order the result by COUNT of view count. This is the query I'm using: SELECT COUNT(DISTINCT view_count.id) AS count, view_count.remove, view_count.video_id, video_index.id AS video_id, video_index.active, video_index.remove, video_index.title AS title, video_index.date_published AS date_published,...

Javascript constructor function to count the number of instances

javascript,object,constructor,count
Okay, so I want to create a constructor function in javascript which will count the total number of instances which are created using this constructor. var Component = function(name) { this.name = name; this.add = function(){this.prototype.countInstances++;}; this.add(); }; and Component.prototype.countInstances=0; As I understand it correctly, the countInstances variable is added...

python pandas: Simplest way to perform group by and extract count of unique entities?

python,pandas,count,group-by,unique
my df: nr,name 1,sam 2,sam 1,mar 1,sam 2,tom 2,jack 1,mar How can I group by 'nr' and count distinct names in 'name' column? this must be a very easy command in all languages like mysql(groupby and distinct command) but I cannot find this in pandas. Can anybody help?...

Count amount of inputfields with the same name in PHP?

php,input,count
I want to count the amount of inputfields with the name "termin"+number+"_von". So if there is one Inputfield with the name "termin1_von", a secound with the name "termin2_von" and third with the name "termin3_von" the code should print "123". cause there are 3 Inputs. What I want is that I...

Find the equal sets of strings and their count (distinct lists)

c#,linq,count,set,distinct
I'm trying to find the distinct sets and their count. Say you have the following model. public class AModel { public IList<string> Tags { get; set; } } And you have a list of the above model, let's say 50.000 instances of AModel with 1...N Tags. I need to find...

Trying to use output of one function to influence the next function to count words in text file

python,file,python-3.x,io,count
I'm trying to use one function to count the number of words in a text file, after having this text file "cleaned" up by only including letters and single spaces. So i have my first function, which i want to clean up the text file, then i have my next...

Add SQL SELECT COUNT result to an existing column as text

sql,sql-server,select,count
I have two tables: 1. TABLE [dbo].[ItemCategories]( [Id] [int] IDENTITY(1,1) NOT NULL, [CategoryId] [int] NULL, [StockId] [int] NULL, 2. TABLE [dbo].[Categories]( [Id] [int] IDENTITY(1,1) NOT NULL, [ParentCategoryId] [int] NULL, [CategoryName] [nvarchar](100) NULL, [Slug] [nvarchar](150) NULL And this query in SQL Server 2012 SELECT [CategoryName], [Slug], [ParentCategoryId], [Id] FROM [Categories] ORDER...

Divide columns values by total rows in impala

mysql,sql,count,impala
SELECT COUNT(DISTINCT cgi.sample_idSince Impala does not allow the SET operation, or subqueries in a select statement, I'm having a hard time figuring out how to divide column values by the total number of rows returned. My ultimate goal is to calculate minor allele frequency at each chr:start position. My data...

Laravel 5 - Count the number of posts that are assigned to each category in a blog

php,count,laravel-5
I was wondering what the cleanest way was to count the number of posts that are connected to a category in my blog. Here is how the table relationship is set up. What I have is a hasMany relationship from the Category to the Post models like this: In Categories...

MongoDB - distinct and count, the simplest case

mongodb,count,distinct,mongolab
I have database XXX and collection YYY in MongoDB (using MongoLab). Here is a sample record: { "_id": { "$oid": "551a5asdfsdfsdfs" }, "_class": "com.test.com", "mvid": "d0fffsdfs" } I would like to retrieve all distinct values of the field "mvid" and count them. Here is what found on the internet: db.YYY.aggregate([{...

MySQL COUNT vs SELECT rows performance

php,mysql,performance,count
I have a small table with three columns and using PHP. TABLE (id unsigned int(10), gameid unsigned int(10), userid unsigned int(10)) - id, gameid and userid are indexed. At some point (When a player join a game) system will check if the game already have 100 players in it, if...

SQL: get a count of how many users each user has referred

php,mysql,sql,count
I know what I want but I'm not sure how to ask it, so please bare with me. I have a table called User_Accounts, In that table I have a column named Referred_By. When a new record is added to this table the column id auto increments, In my case...

Impala Query: Combine multiple COUNT DISTINCT WHERE clauses

mysql,sql,count,substring,impala
On impala, I'm trying to count the number of distinct sample id's that contain "101", "102" or "103". Here is an example of my data: | sample_id | ___________ | 101-345-5 | | 101-345-6 | | 101-345-6 | | 102-345-5 | | 103-345-5 | | 103-345-8 | | 103-345-8 |...

Adding to ListView columns not increasing column count

c#,winforms,listview,count,control
I have created a Form using the VS 2013 designer. I added a Listview control and added 13 columns via the Properties window. I then wrote a program in C# and I am able to access all of those columns using the item.SubItems[N] construct. Also, all of those column headers...

SQL SELECT COUNT GROUP BY - error

mysql,sql,count,group
I am having a problem with my sql statement, I have two tables (ogrenci and taksit). I am trying to count the number of taksits where they are zero and group them by KategoriID.KategoriID is both in ogrenci and taksit tables while odendi is only in taksit table. I could...

Excel - list entities (items)

excel,count,excel-formula
Friends, I need to list all the unique entities (items) in a Excel spreadsheet, how to? E.g. **List1** 1 1 1.1 2 a a aa b c c And I need a certain function that returns: **Entities** 1 1.1 2 a aa b c Then I can count the occurence...

Count Number of Objects in Java

java,oop,count
I am creating a program called Humans and Pets. The program simply prints out a list of Human's names (in this case I have created 4) and their corresponding pets. Here is the code: AmazingPets.java public class AmazingPets { /** * @param args the command line arguments */ public static...

MySQL Conditional count based on a value in another column

mysql,count,distinct,condition
I have table that looks like this: id rank a 2 a 1 b 4 b 3 c 7 d 1 d 1 e 9 I need to get all the distinct rank values on one column and count of all the unique id's that have reached equal or higher...

Count unique values based on the newest element in a multidimentional array - PHP

php,arrays,count
Well basically, I have a multidimentional array that I want to count state, but sometimes in the array I can get duplicate lid, so I got to get the lid with the newest date_add [0] => Array ( [lhid] => 181 [lid] => 183 [uid] => 1 [state] => 2...

Count() function in mysql

mysql,count
my count function counts the records of the first table twice then add to that same result rather than add the count() of the two table records. How can I work around this? SELECT uln.user_id, count(uln.user_id)+count(uln.user_id) as user_pet_notif_count FROM user_legislation_notifications uln join user_petition_notifications upn on upn.user_id = uln.user_id where uln.user_id...

EXcel COUNT values based on multiple conditions in different ranges

arrays,excel,count,multiple-conditions
I have an Excel spreadsheet, contain all possible combinations between certain products, e.g. a-a, a-b, a-c, b-a, b-b, b-c, c-a, c-b and c-c. Based on those combinations, a value is calculated and compared with a historical value. The two values are subtracted, resulting in -1, 0 or 1. Now, in...

Display Count(*) in PHP

php,mysql,mysqli,count
I want to display the number of rows with the word in a string of a column having "LIV" in it . This is my code. When i run query in phpmyadmin the result shows I have 2358 rows but when run in php it says only 1 row ....

Sort and counting a column without uniq in bash

linux,bash,sorting,count,sh
I want to add a count of only the first column using bash, without doing uniq, like this: input: 58311s2727 NC_000082.6 100.00 50 58311s2727 NC_000083.6 100.00 60 58311s2727 NC_000084.6 100.00 70 58310s2691 NC_000080.6 100.00 30 58310s2691 NC_000081.6 100.00 20 58308s2441 NC_000074.6 100.00 50 output: 3 58311s2727 NC_000082.6 100.00 50 3...

count cells quantity with a special contained word and calculate the percentage

string,excel,count,percentage
How can I count cells quantity with a special contained word and calculate the percentage in excel? For example I have a survey database about a product. the feedbacks are "Good, Not Bad, Bad". I want to count the quantity of each type of feedbacks and finally calculate the percentages...

SQL Server 2012 Count

sql-server,count
I'm using SQL Server 2012. I have a table CustomerMaster. Here is some sample content: +--------+---------------+-----------------+-------------+ | CustNo | NewMainCustNo | Longname | NoOfMembers | +--------+---------------+-----------------+-------------+ | 3653 | 3653 | GroupId:003 | | | 3654 | 3654 | GroupId:004 | | | 11 | 3653 | Peter Evans |...

MySQL Multiple Conditions on Group By / Having Clause

php,mysql,count,group-by,having-clause
I have three tables that are all inter-related with the following structure. ModuleCategory Table: +------------------+----------------+------------+ | ModuleCategoryID | ModuleCategory | RequireAll | +------------------+----------------+------------+ | 90 | Cat A | YES | | 91 | Cat B | NO | +------------------+----------------+------------+ ModuleCategorySkill Table: +------------------+---------+ | ModuleCategoryID | SkillID | +------------------+---------+ |...

Counting the number of pairs in a vector

r,count,duplicates,categories
Suppose that I have the following vector: V<-c(-1,-1,1,1,1,-1,-1,1) And I want to know the number of different pairs in the following categories: (1,1), (-1,1), (1,-1), and (-1,-1) In my example, there is exactly 1 pair of each. I have been trying to solve this problem with the function split and...

Understanding the issues of bit copying [closed]

c++,count,copy-constructor
I am trying to understand the following code: blueberry bitCopy(blueberry a) { cout << "bitCopy " << blueberry::blQuantity << endl; return a; } void howMany() { cout << blueberry::blQuantity << endl; } int main() { blueberry firstBl; howMany(); bitCopy(firstBl); howMany(); } class blueberry: #ifndef header_h #define header_h #pragma once #include...

complex mysql query DISTINCT

mysql,sql,select,count,distinct
I want to get count how much 'teams' have 5 or more 'paid=1' players. I tried.. SELECT COUNT (DISTINCT team) FROM players WHERE paid=1 ...but result is 32 where 27 teams have paid 5 players, 5 have paid less than 5. How to edit this query to get only count...

python count files and display max

python,count
I am tying to count al file extenties in a directory. And then count them and display how many of them are there. What is the best way to make this? This script gonna be really big with al the pdf= 0 lines of code. Also how can I display...

Why does '12345'.count('') return 6 and not 5?

python,python-3.x,count
>>> '12345'.count('') 6 Why does this happen? If there are only 5 characters in that string, why is the count function returning one more? Also, is there a more effective way of counting characters in a string?...

Count multidimensionnal array

php,arrays,count
I have my main array: array(6) { [1]=> array(3) { [0]=> string(15) "Extension" [1]=> int(1) [2]=> string(6) "3,00 " } [2]=> array(3) { [0]=> string(32) "Physics " [1]=> string(1) "1" [2]=> string(6) "3,00 " } [3]=> array(3) { [0]=> string(31) "Physics " [1]=> int(1) [2]=> string(6) "6,00 " } [4]=>...

sql select 5 higest values

sql,sql-server,count,select-query
I'm trying to select the 5 rows with the highest count value This is my query: string sql = "SELECT top 5 count FROM Likes ORDER BY COUNT(*) DESC"; It's just throwing an error code that Column 'Likes.count' is invalid in the select list because it is not contained in...

Efficiently finding the count of column values for distinct rows in a dataframe in r

r,count,subsetting,memory-efficient
Suppose I have a data frame as: id value 1 "hi" 1 "hi" 1 "hi again" 1 "hi again" 2 "hello" 2 "hi" Now I want to get the count of each value for each of the distinct values in id column. The output would be like id value Freq...

PHP - Create unique id number for each item

php,count,increment
I have an image array loop, and it successfully loops through my image items. However, I need to give the 'data-slide-index' attribute for each item a unique number, starting from 0, adding 1 for each following item (0 - 9 if there are ten images in total). I realize this...

Select ID having maximum count of another ID

mysql,sql,count
I have a database of baseball plays with a PlayerID and a TypeID (the kind of play: double, strike out, etc). The data looks something like this: +----------+--------+ | playerid | typeid | +----------+--------+ | 2 | 4 | | 2 | 4 | | 2 | 7 | |...

MySQL COUNT on multiple relations

mysql,database,join,count
I am trying to figure out how to return the counts of multiple different items in seperate tables related to the table i am joining too. Im quite new to joins so im not sure if im using correct join. hopefully you can help me! the tables would be like...

SQL display months when Count is 0 [duplicate]

sql,date,count,sql-server-2008-r2,datepart
This question already has an answer here: Include monthly counts including months where data doesn't exist 1 answer I was wondering if someone could help me... I have the following SQL query (have shortened this down as its a large union query) SELECT [ Month ], sum(total) from (select...

C code Count elements in array that are not null

c,arrays,count,element
going over old exam papers and doing questions, for this one: array is: char* s[]={"one","two",NULL,NULL,"five","",""}; using function name: int inUse(char *s[],int len) I have to determine the number of elements that are not NULL. I have come up with: int count=0; for(i=0; i<7, i++) { if(s !=NULL) { count ++;...

SPARQL: How do I List and count each data type in an RDF dataset?

types,count,sparql
I am trying to count the instances of each datatype in a dataset. It is a simple dataset with only three data types: integer, string and dateTime. I can get the number of datatypes (3) by querying: SELECT (COUNT(DISTINCT datatype(?o)) AS ?dTypeCount) {?s ?p ?o. FILTER (isLiteral(?o)) } GROUP BY...

SQL COUNT- not a single group group function error

sql,oracle,count,group-by,aggregate-functions
I run the following COUNT(*) query on Oracle DB: select count(*) + (select count(*) from t_diagram) from t_object I get the following error: Not a single group- group function. I understand that using aggregation methods (e.g. SUM, AVG) require a GROUP BY statement. However, how can I add a GROUP...

Count the number of consecutive pairs in a vector

r,table,count,split,categories
Suppose that I have the following vector: V<-c(-1,-1,-1,-1,-1,-1,-1,-1,1,1) and I want to count the number of CONSECUTIVE pairs in the following categories: (1,1), (-1,1), (1,-1), and (-1,-1). In my example, there are seven consecutive pairs of (-1,-1), one pair of (-1,1), and 1 pair of (1,1). I am trying to...

Count occurrence of unique variables

r,count,statistics
I have a data frame of variables, some occur more than once, e.g.: a, b, b, b, c, c, d, e, f I would then like to get an output (in two columns) like this: a 1; b 3; c 2; d 1; e 1; f 1. Bonus question: I'd...

fastest way to compare text file content

python,string,python-3.x,count
I have a question to help streamline my programming. So I have this file text.txt and in it I want to look through it and compare it with a list of words words and each time the word is found it adds 1 to an integer. words = ['the', 'or',...

PL/SQL Packages inserting count Number autmomatically in variable

oracle,variables,plsql,count,package
the Exercise is: Create a public variable in a package called v_Guest_Count that is automatically initialised with the number of Guests in the Guests table. Use the following SQL: SELECT COUNT(*) FROM Guests; I tried it like this but it won't work: create or replace PACKAGE BODY BEACHCOMBER IS v_guest_count...

Count from associate table

ruby-on-rails,activerecord,count
I want to have some stats from my app, User can publish post that I call Idee, and I want to know how many user have publish at least one idee. I'm assuming that should be something like: @total_user_active = User.where(idee.size >= 1).count But this doesn't work. It's user who...

How to retrieve the most present pair in groups of three columns, with MySQL?

mysql,count,group
I am working on ice hockey software: trying to find out who in your team has collected the most points with a specific player (in this example user_id = 1). Data structure: goal_user_id | assist_user_id | second_assist_user_id ----------------------------------- 1 | 13856 | null 1 | 15157 | null 1 |...

While using string.count() method I am getting an error, TypeError: expected a character buffer object

python,count
s = "That that is is that that is not is not is that it it" sub = "s" print "str.count(sub, 4, 40) : ", str.count(sub, 4, 40) While using string.count() method getting the following error. Error : TypeError: expected a character buffer object ...

MySql - count from beginning until each day

php,mysql,count
Let's say I have the following table (keep in mind that this table will have 10000+ rows): id total date 1 5 2015-05-16 2 8 2015-05-17 3 4 2015-05-18 4 9 2015-05-19 5 3 2015-05-20 I want the query to give the following result: 1 date => 2015-05-16 total =>...

R — frequencies within a variable for repeating values

r,count,duplicates
I've got a column A, which has several values, some of them repeating. So, example: A = c(5, 9, 6, 5, 5). I need to go through A and count the frequencies of each of the values in A. So, for this example, for the set of 5s in A,...

PHP count not working [closed]

php,count
I have an array that have the size 2: Array ( [0] => VP/vnyAf8TuTENi6xQr1a7ZUg+LtJitd1TwUHCuqSmSqRM1EGDaGkArssU7Ag/aZzwjuIPvQ3wGskhs0b85j2ANnX3KZ4JUTMwcMMAI0eXd+FO5wjZLWfhOa1gyhIwhD [1] => e0k59g4lqV/AcJRE9apOlem3mT4lNuG0TJhfFcypZ6HR7bAnUxrstxz/JdAQLeb/E4+0pfYmiIuqr4N+O3L1RDvSIKXA3J/ubOKmiz+Yo5Vz5ml91VZ1DR8eHWaP1vE9 ) echo count($credentials); This prints: 2 But somehow for the following code I enter in the first condition and "a" is printed if(count($credentials !== **2**)){ echo "a"; } else { echo "b"; }...

minimum date among several columns

sql,count,min
I'm trying to get a count of a number of policies issued per month. This is close to returning the correct information: SELECT count(policy_no), left(issue_date,6) FROM table_a WHERE indicator = 'fln' GROUP BY left(issue date,6) the indicator is narrowing it down to the types of policies I want. The only...

Echoing data from MySQL

php,mysql,count,echo,add
I have a Table in MySQL that stores data as such: Name Amount Time Person 1 1 Time Person 2 1 Time Person 3 1 Time Person 1 1 Time Person 2 1 Time Person 3 1 Time Person 1 1 Time I want to echo these reults so they...

LINQ: Count Users in 3 way join

linq-to-sql,count
I'm having trouble with LINQ to SQL, which I think should not be too difficult. In SQL I have a BusinessUnits, that get's divided in OrgUnits, and Users belong to an Org Unit. I want to print the BusinessUnitID with the number of Users in each. In SQL, it will...

Get column value on count (MySQL/Java)

java,mysql,count,value
I'm trying to get the number of times where a username has been found in a table, the thing is that I am just getting a value of "1" every time, even if the username is not found (where the value should be 0) I think the problem is that...

SQL Server : select count of Todays Transactions

sql,sql-server,count
I was wondering if someone could help me as I can't seem to find an answer to the following that I have been searching for. Select Count(pm1.number) As number From SCenter.probsummarym1 As pm1 Where pm1.open_time >= Today() I have the above that works great if I put in the date...

google-apps-script count files in folder

if-statement,google-apps-script,count,google-drive-sdk
I've had a search but cannot seem to find what I am looking for. I am seeking the code to enable me to do this pseudocode: Count number of files in specific Google Drive folder (by folder Id) If file count is above 'x' do this {other piece of code}...

PostgreSQL Order by not working, it doesn’t returns values according to the order

postgresql,count,group-by,sql-order-by
I have two tables players and scores. On the player table I have two fields, name and id (PK) On the scores I have several fields [id_score(PK),winner and looser are foreign key to the id of the player] id tournament and id match. Players id_players | name ------------+----------- 41 |...

I need to find the longest word in a sentence using JS

javascript,html,count,return
I am having trouble getting my JS to return the longest word when I click on the button. I am not sure what in my JS code I am missing or have put incorrectly, but when I type in three words nothing is given back to me. I have pasted...

SQL query display min count rows only

sql,oracle11g,count,min
I am trying to only display the cost value of cars which belong to categories with the minimum category count totals This the query I am trying to use: select model, VIN,cost from stock Desired Output: Model - VIN - Cost STI XXXXXXXXXXXX $55,000 I understand that a having operator...

MySql : issue with GROUP BY and COUNT clauses

mysql,sql,select,count
I have this table I would like to display products(with their type) that have at least two different types. Here : I have tried this : SELECT PRODUCT, TYPE FROM MYTABLE group by PRODUCT, TYPE HAVING count(PRODUCT) > 1; but it doesn't give me the result I want....

Select and create month row and count the data - MySQL

mysql,count
I had a problem. I have the data like below: ----------------------- | last_login_dt | ----------------------- | 2015-08-11 08:06:36 | | 2015-06-10 22:06:43 | | 2015-06-11 08:06:58 | | 2015-09-11 08:06:45 | ----------------------- So far, I managed to count this kind of data and turn into this using below statement: SELECT...

How to count business days from a given date in SQL Server using a calendar reference table

sql-server,date,count,calendar
I have two tables. One table is a Calendar that has a date column and a kindofday column. The kindofday column contains 'bankday', 'saturday', 'sunday' and 'holiday'. I need to account for holidays otherwise there are several queries on the net that would work... date kindofday 1999-08-24 00:00:00:000 bankday I'm...

Getting the count of the second index in a muti-dimensional array PHP

php,arrays,multidimensional-array,count
I want to get the count for the second index in an array, and have searched for quite a while, but still haven't found an answer, and still have no idea how. Please take a look: $array[0][0] = 1; $array[0][1] = 2; $array[0][2] = 3; $arrayCount = count($array); echo $arrayCount;...

Saving the click counts of an item each item it is clicked

javascript,php,count,save,value
Currently I try to build up a like counter for my web page. Below you can see the click counter. It's fully working. Sadly (but for sure) just for the current session... Is there any possibility to store the value forever? One last thing! On the website is more than...

select all but sort by count in postgresql

postgresql,sorting,table,count
This is my third ask, so im newbie jet :B Before to ask, you must to know my English is not so good, so I'll try to do my best. I have a table myTable with a lot of columns, keep in mind this table is too big, and one...

Counting up “broadly”: Not 0,1,2,..,9,10,11,..,99 but 00, 01, 10, 11, 02, 12, 20, 21, 22, 03, .., 99

math,count,language-agnostic,numbers,sequence
When a counter is made up from a fixed number of digits (2 in the title), standard counting-up works by incrementing from the least to the most significant digit and upon overflow reset it. I want to count differently: A 4 digit number in base-10 would be counted up in...

Counting word occurrences in a file C

c,string,count
Welcome everybody. I am new to Stackoverflow, I code in C for some time. I have run to a problem writing a program counting word occurrences in a text file. I need to have an output telling what word occurred how many times. Here is the source code: #include <stdio.h>...

MYSQLI rows calculate is too slow

php,mysql,mysqli,count,rows
I am trying to calculate the visitors on my table with SQL_CALC_FOUND_ROWS with MYSQLI but it's slow .It's over 15 seconds.What can i do make it faster ? I have to mention that my table is MyISAM and has in total over 2 million rows. if ($result = $mysqli->query("SELECT SQL_CALC_FOUND_ROWS...

Count number of occurences in repeated variables (r)

r,count,summary
I need to summarise the number of days that people have worked during a week. Each variables represent a day. I need to produce a summary of the number of days worked. I am not quite sure what would be a convenient manner to do it (beside summing the table...

shell script for counting replacements

bash,replace,count
Ten files located in a directory. Each file content has "apple" word. write a bash shell script to replace "apple" with "banana" in all ten files and Print the number of replacements for each file. Have tried in this way but dont know how to get number of replacement. can...

SQL count date time

sql,count,concatenation
I have to concatenate the date and time portion of two fields, which I have managed to do, then I need to test if the result is < getdate() select count(cast(cast(DischargeDatenew as date) as datetime) + cast(DischargeTime as time))as Requiredby FROM [dbo].[Main] where Location = 'Home' and ScriptTypeID = '1'...

Simple Table with dplyr on Sequence Data

r,count,dplyr,summary
I would like to make a simple table with dplyr and summarise But I can't really figure out how ... (Even though it should be quite simple). I have a matrix of sequences. When I simply tabulate table(dta) I have the result I want. dta acquaintance alone child notnotnot nuclear...

Counting all .class files

linux,bash,shell,count
I want to count all .class file in my project directory. I am working on ubuntu. I can list all the class file like this - find . -type f -name '*.class' It lists a lot of .class files. But I want to know the count of these .class files....

Regex/Algorithm to find 'n' repeated lines in a file

regex,algorithm,count,find,duplicates
I am looking for an advanced version of this. Basically, if I have a file with text: abc ghi fed jkl abc ghi fed I want the output to be:(for n=3) Duplicated Lines abc ghi fed Times = 2 ...

Excel: Count of unique items while ignoring junk duplicates

excel,count,duplicates
I have a column with IDs and I need a count of the unique IDs only. The problem is that not all rows have unique IDs so those rows have a junk code of 99999. Also there can be text in the ID sometimes and it looks like this: D-00000...

Oracle COUNT() function

sql,oracle,count
I have this query: select dates,To_char(dates,'DAY') DAYs FROM ( select trunc(ADD_MONTHS(sysdate,-1),'MM') + level -1 Dates from dual connect by level <= ADD_MONTHS(trunc(sysdate,'MM'),1)-1 - trunc(sysdate,'MM')+1 ) Where To_char(dates,'DY') NOT IN ('SA','SO') The output of query above is: 01.05.2015 FREITAG 04.05.2015 MONTAG 05.05.2015 DIENSTAG 06.05.2015 MITTWOCH 07.05.2015 DONNERSTAG 08.05.2015 FREITAG 11.05.2015 MONTAG...

Return frequency of string in MYSQL column with PHP

php,mysql,count
after searching for several questions, i'm still struggling with mysql queries in PHP, my current goal is to do a MYSQL query that counts how many repeated strings are in a column and then return this amount in a INT variable to be written in the database. The current code...

Pivot Tables or Group By for Pandas?

python,pandas,count,group-by,pivot-table
I have a hopefully straightforward question that has been giving me a lot of difficulty for the last 3 hours. It should be easy. Here's the challenge. I have a pandas dataframe: +--------------------------+ | Col 'X' Col 'Y' | +--------------------------+ | class 1 cat 1 | | class 2 cat...

Mysql count and return just one row of data

mysql,join,count,subquery,having
I need to count the amount of users that have have answered all of those 3 profile_options (so they have at least 3 records in the profile_answers table). SELECT COUNT(DISTINCT(users.id)) users_count FROM users INNER JOIN profile_answers ON profile_answers.user_id = users.id WHERE profile_answers.profile_option_id IN (37,86,102) GROUP BY users.id HAVING COUNT(DISTINCT(profile_answers.id))>=3 The...