count

SQL - Use results of a query as basis for two other queries in one statement

I'm doing a probability calculation. I have a query to calculate the total number of times an event occurs. From these events, I want to get the number of times a sub-event occurs. The query to get the total events is 25 lines long and I don't want to just copy + paste it twice. I want to do two things to this query: calculate the numb...

Needed: Wrappable Counter where < and > do "the right thing", language C

Hi Folks, I need the code to a couter that is allowed to overflow and where < > continue to tell earlier values from later values, for some defined interval. To clarify, one possible implementation would be: Consider two such counters cur and dut (device under test), consider two functions: bool isEarlier(cur, dut) // Is dut earl...

How do I get the _count in my content provider?

What should I do to get my content provider to return the _count column with the count of records? The documentation says it is automatic, but maybe it's only taking about some built-in content provider. Running a query to the database seems not to return it. ...

Counting lines, words, characters and top ten words?

Hi I'm pretty new to Stack Overflow so I hope that I'm doing this correctly and that someone out there has the answer I need. I'm currently coding a program in Java with Eclipse IDE an my question is this: I need a snippet of code that does the following It's supposed to get a .TXT file containing text and from that .TXT file count t...

mysql count only for distinct values in joined query

WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find another way to say it. I have a table of people and a table of links to photos and videos. I join the people to the media, and of course a person can have more than one piece of media. I am attempting to grab the first 30 people and all of their media in ...

Can anyone show me why my SQL query isn't working (see details)?

I used the following query to find duplicates: SELECT userID, COUNT(userID) AS NumOccurrences FROM userDepartments GROUP BY userID HAVING ( COUNT(userID) > 1 ) I then tried adding an inner join so I could see the user names that match, which are stored in a different table. SELECT userDepartments.userID, users.firstname, users.lastna...

How to create a reliable and robust page view counter in a web application?

I want to count the visits on a web page, and this page represents an element of my model, just like the Stack Overflow question page views. How to do this in a reliable (one visit, one pageview, without repetitions) and robust (thinking on performance, not just a new table attribute 'visits_count') ...

php count error

As you see I have created drop down and give it name the field name, and I have also the count function. What I want to do is, if some select drop down menu..show the how many result found in number like 10, 20,.. if the second dropdown selected it will check the two drop down selected and pass the result count..like that continuous..if...

Linq with Left Join on SubQuery containing Count

I'm having difficulty translating sql to linq syntax. I have 2 tables (Category and CategoryListing) which reference each other with CategoryID. I need to get a list of all the CategoryID in Category Table and the Count of CategoryID for all corresponding matches in the CategoryListing table. If a CategoryID is not present in Category...

Using foldl to count number of true values

I'm trying to find a way to do the following function with foldl: count a = length (filter (\i -> i) a) It just counts the number of values that are true in a list of booleans. I did try it myself with count = foldl (\i -> case i of True -> (1+) False -> (0+) ) 0 Which did not even compile. Any suggestion...

Count array counts 1 too many

Does anyone know how to get arround the annoying problem that when counting how many values there is inside an array if the value is 0 it says 1 becuase it counts the name or something. So like this: 0 : 1 1 : 1 2 : 2 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 Thnaks, Stanni ...

Select COUNT(*) of subquery without running it twice

I've got a procedure to return a result set which is limited by page number and some other stuff. As an OUTPUT parameter I need to return a total amount of selected rows according to the parameters except the page number. So I have something like that: WITH SelectedItems AS (SELECT Id, Row1, Row2, ROW_NUMBER() OVER (ORDER BY Row1) AS Po...

SAS Web Report Studio - how to count distinct values in crosstabs

Hello, in SAS Web Report Studio 3.1 I need to count distinct occurences for selected dimensions and display the results in a crosstable. According to the SAS Support Web site this aggregate function is not supported in cross tablulations, but maybe there is a work-around? Thank you and best Regards Nadine ...

MySQL statement combining a join and a count?

I've got a table of 'folders'. I want to return all the records with the userId of 16. SELECT * FROM `folders` WHERE userId = 16; I've got a table of 'files'. For each 'folder' returned above, I want to return a count of 'files' within that 'folder'. SELECT COUNT(*) as "Files" FROM files WHERE Folder = n; How do I combine these? I'...

How to get the number of rows of the selected result from sqlite3?

I want to get the number of selected rows as well as the selected data. At the present I have to use two sql statements: one is select * from XXX where XXX; the other is select count(*) from XXX where XXX; Can it be realised with a single sql string? I've checked the source code of sqlite3, and I found the function of sqlite3_changes()....

How to retrieve the total row count of a query with TOP

I have a SQL Server 2008 query SELECT TOP 10 * FROM T WHERE ... ORDER BY ... I'd like to get also the total number of the rows. The obious way is to make a second query SELECT COUNT(*) FROM T WHERE ... ORDER BY ... Is there an efficient method? Thanks ...

How to get data back from Mysql for days that have no statistics

Hello all, I want to get the number of Registrations back from a time period (say a week), which isn't that hard to do, but I was wondering if it is in anyway possible to in MySQL to return a zero for days that have no registrations. An example: DATA: ID_Profile datCreate 1 2009-02-25 16:45:58 2 2009-02-25 16:45:58 3 2009-02...

Recursively counting files with PHP

Simple question for a newb and my Google-Fu is failing me. Using PHP, how can you count the number of files in a given directory, including any sub-directories (and any sub-directories they might have, etc.)? e.g. if directory structure looks like this: /Dir_A/ /Dir_A/File1.blah /Dir_A/Dir_B/ /Dir_A/Dir_B/File2.blah /Dir_A/Dir_...

Unable to count the number of matches in Vim

How can you count the number of matches in Vim? For instance, for the text <? ...

MySQL: Retrieve Unique Values and Counts For Each

Is there a simple way to retrieve a list of all unique values in a column, along with how many times that value appeared? Example dataset: A A A B B C ... Would return: A | 3 B | 2 C | 1 Thanks! ...