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...
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 ...
Anyone know an R function that will return the number of items in a list?
Thanks
Karl
...
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?
...
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...
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?
...
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...
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
...
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...
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 = []
...
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 do you count duplicates in a ruby array?
For example, if my array had three a's, how could I count that
...
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...
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...
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
(
...
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...
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...
I need to reset my table counter back to 0 - is there a MySQL command for this?
...
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...
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 ...