count

C++ string manipulation / input

This is for homework! But I need help anyway. The assignment is to input a sentence then output the number of words, and the number of occurrences of each letter. The output must have the letters in alphabetical order. So far, I've been able to count the number of words and get all the letters to lower case so that I'll be able to keep c...

Mysql get count of rows for each day

My Current query is: SELECT DISTINCT DATE(vote_timestamp) AS Date, COUNT(*) AS TotalVotes FROM `votes` WHERE vote_target_id='83031' GROUP BY DATE(vote_timestamp) ORDER BY DATE(vote_timestamp) DESC LIMIT 30 (line breaks separated for readability) Where vote_timestamp is a time for each "vote", Count(*) is the count for that day, and ...

R: count number of objects in list

Anyone know an R function that will return the number of items in a list? Thanks Karl ...

Most efficient way to count all rows in a table but select only one

Currently I'm running these two queries: SELECT COUNT(*) FROM `mytable` SELECT * FROM `mytable` WHERE `id`=123 I'm wondering what format will be the most efficient. Does the order the queries are executed make a difference? Is there a single query that will do what I want? ...

Consolidating a COUNT query

I have a page where I am running an initial SQL query to get a list of subjects, then I loop over this query and run two additional queries for each record returned from the original subjects query (I happen to be doing this in ColdFusion, but not sure that really matters). These two additional queries do COUNTs for that specific subjec...

Sql COUNT Performance Question

Structure of Example table: Id, Integer (PK) Name, Varchar(100) Description, Text I need to know if exists difference in performance between: SELECT COUNT(*) FROM Example; and SELECT COUNT(Id) FROM Example; Or does not exists differences? ...

SQL Joins, Count(), and group by to sort 'posts' by # of yes/no 'votes'

I have posts, votes, and comments tables. Each post can have N 'yes votes', N 'no votes' and N comments. I am trying to get a set of posts sorted by number of yes votes. I have a query that does exactly this, but is running far too slowly. On a data set of 1500 posts and 15K votes, it's take .48 seconds on my dev machine. How can I opti...

How to count all the enums in a SQL table.

Okay so I have a database field called moderated It is an ENUM with 3 values: approved denied unmoderated How can I write a query that counts the amount of each, so I can generate this output: Approved: 3 Denied: 10 Unmoderated: 23 ...

SELECT command to calculate percentage

I'm trying to get the percentage of each video I have in my database based on its view count against all other videos. I'm then trying to display all the videos from highest view count to lowest, displaying its percentage on its side inside a nice HTML page. Obviously the percentage would range from 0 - 100% (and not over) and the mos...

Conditional counting in Python

Hello there, not sure this was asked before, but I couldn't find an obvious answer. I'm trying to count the number of elements in a list that are equal to a certain value. The problem is that these elements are not of a built-in type. So if I have class A: def __init__(self, a, b): self.a = a self.b = b stuff = [] ...

MYSQL fetch 10 posts, each w/ vote count, sorted by vote count, limited by where clause on posts

I want to fetch a set of Posts w/ vote count listed, sorted by vote count (e.g.) Post 1 - Post Body blah blah - Votes: 500 Post 2 - Post Body blah blah - Votes: 400 Post 3 - Post Body blah blah - Votes: 300 Post 4 - Post Body blah blah - Votes: 200 I have 2 tables: Posts - columns - id, body, is_hidden Votes - columns - id, post_i...

How to count duplicates in Ruby Arrays

How do you count duplicates in a ruby array? For example, if my array had three a's, how could I count that ...

Displaying record count - Ruby on Rails - Ajax

I am new to rails so sorry if sometimes I don't make much sense. Here is what I am trying to do. I am trying to build a vote system. So next to a blog post there is a link that says 'vote' (will probably say like later). So far I have working: when the vote button is clicked, a value of '1' is delivered to the vote table and then that pa...

Is there a svn:keyword for "modification count" of a versioned file in subversion

The $Revision$ in CVS shows the version of a file, which based on modification count. This is very convienient, as the modification count can be used as "Build Number", and for each file, the number itself reflects the "growing life" of a file. But in SVN, the version is about the whole repository, any modification to files are by me...

SQL Server Search, how to return the total count of rows?

Hello, I have another post which resulted in this SELECT DISTINCT a.ArticleID, COUNT(*) AS KeywordMatch, a.Headline, a.ShortDescription, a.CategoryID, a.ArticleSectionImage, a.DatePublished FROM Article a JOIN SearchWords sw ON a.ArticleID = sw.ArticleID WHERE EXISTS ( ...

Oracle SQL Count Function Display Only One Value

I am learning SQL for a personal projects and seems that I don't quite get the COUNT function. I have a "sample" table with this sample data: NAME COLOR Tom red Tom blue Jerry yellow Keri yellow Paul red Bob yellow Bob red Mary green What I am attempted to do is print out only those NAME values that have only one COLOR va...

Sub-query Optimization Talk with an example case

Hello guys, I need advises and want to share my experience about Query Optimization. This week, I found myself stuck in an interesting dilemma. I'm a novice person in mySql (2 years theory, less than one practical) Environment : I have a table that contains articles with a column 'type', and another table article_version that contain a...

MySQL Resetting the index count to 0

I need to reset my table counter back to 0 - is there a MySQL command for this? ...

Counting all the posts belonging to a category AND its subcategories.

I would really appreciate some help with my problem: I have 2 MySQL tables, categories and posts, laid out (simplified) like so: categories: CATID - name - parent_id posts: PID - name - category What I would like to do is get the total amount of posts for each category, including any posts in subcategories. Right now I am getting...

SELECT COUNT(DISTINCT name), id, adress from users

Hi, With PHP I'm trying to run a SQL query and select normal columns as well as COUNT. $sql_str = "select COUNT(DISTINCT name), id, adress from users"; $src = mysql_query($sql_str); while( $dsatz = mysql_fetch_assoc($src) ){ echo $dsatz['name'] . "<br>"; } The problem is that when I have "COUNT(DISTINCT name)," in my query, it ...