count

Mysql count frequency

穿精又带淫゛_ 提交于 2020-01-11 09:04:51
问题 I've checked similar questions but it didnt help in my precise question. So, my table goes like this: id age 1 30 2 36 3 30 4 52 5 52 6 30 7 36 etc.. I need to count the frequency of ages: age freq 30 2 36 3 52 2 How can I grab this freq? After this I will need to work with that data, so it might be necessary using array? Thanks! function drawChart() { // Create the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'age'); data.addColumn('number', 'freq');

mysql show Count of rows from other table in each row

大憨熊 提交于 2020-01-11 08:45:30
问题 select `personal`.`id` AS `id`, `personal`.`name` AS `name`, (select count(visit.id) from visit,personal where visit.user_id=personal.id) as count from personal; im trying to get all users and the counts of visits they did. the result i get is all users but the count column contain same value (not specific to that row id). what am i doing wrong here ? how to tell mysql to user this row id ? is compound select optimum way to do it or is there a better way ? 回答1: SELECT p.id, p.name, COUNT(v

MYSQL last login and number of logins in last 3 months

*爱你&永不变心* 提交于 2020-01-11 06:32:11
问题 I'm trying to write a query to join a user table to an activity logging table and return the following for each user: A) The time they last logged in. B) The number of logins in the last 3 months. This is what I have come up with so far: SELECT A.UserID, COUNT( Activity ) AS Logins, MAX( TIME ) AS LastLogin FROM UserMaster A LEFT JOIN UserWebActivity B ON A.UserID = B.UserID AND Activity = 'Login' AND TIME BETWEEN DATE_SUB( NOW( ) , INTERVAL 3 MONTH ) AND NOW( ) GROUP BY A.UserID This almost

FOUND_ROWS() keeps returning 0

风格不统一 提交于 2020-01-11 03:40:13
问题 $result = $db_con->query("SELECT SQL_CALC_FOUND_ROWS * FROM users LIMIT 0,10"); $count_result = $db_con->query("SELECT FOUND_ROWS() as totalcount"); $row = $count_result->fetch_assoc(); $total = $row['totalcount']; $total keeps returning 0 even though the $result contains all the user rows in it. ini_set("mysql.trace_mode", "0"); I found out about this setting via searching a similar Q on here, but it did not resolve my issue. When I use the 2 select statements in my MySQL client it always

Counting chars in sequences via SQL

女生的网名这么多〃 提交于 2020-01-10 04:52:13
问题 I have a database with a sequence table. Each (amino acid) sequence in this table comprises of 20 different chars (A, V, ...). For instance "MQSHAMQCASQALDLYD...". I would like to count the number of appearance of each char, so that I get something like "2xM, 3xQ, ...". Furthermore, I would like to do this over all sequences in my DB, so I get the overall appearance of each char. ("248xM, 71x W,..."). How can I do this in PostgreSQL? At the moment, I am doing it with Ruby, but I have 25,000

Why does “test”.count('') return 5? [duplicate]

安稳与你 提交于 2020-01-09 10:39:16
问题 This question already has answers here : Why are str.count('') and len(str) giving different output? (3 answers) How does the count() method work? [duplicate] (1 answer) Closed 2 years ago . This is a short one, yet very irritating. I know I can count the amount of times a string occurs within another string like this: 'banana'.count('a') >>>3 meaning that banana contains the letter "a" 3 times. This is where it gets kind of weird. My first confusion is - when I do 'foo'.count('') , what does

Why does “test”.count('') return 5? [duplicate]

浪尽此生 提交于 2020-01-09 10:39:11
问题 This question already has answers here : Why are str.count('') and len(str) giving different output? (3 answers) How does the count() method work? [duplicate] (1 answer) Closed 2 years ago . This is a short one, yet very irritating. I know I can count the amount of times a string occurs within another string like this: 'banana'.count('a') >>>3 meaning that banana contains the letter "a" 3 times. This is where it gets kind of weird. My first confusion is - when I do 'foo'.count('') , what does

Count occurence of a word by ID in python

一笑奈何 提交于 2020-01-07 08:32:07
问题 Following is the content of a file,My question is how to count the number of occurences for the word "optimus" for different IDs ID67 DATEUID Thank you for choosing Optimus prime. Please wait for an Optimus prime to respond. You are currently number 0 in the queue. You should be connected to an agent in approximately TIMEUID.. You are now chatting with AGENTUID 0 ID67 Optimus MEMORYUID Hi there! Welcome to Optimus prime Web Chat. How can I help you today? 1 ID67 Optimus DATEUID I like to pay

Count occurence of a word by ID in python

本秂侑毒 提交于 2020-01-07 08:31:57
问题 Following is the content of a file,My question is how to count the number of occurences for the word "optimus" for different IDs ID67 DATEUID Thank you for choosing Optimus prime. Please wait for an Optimus prime to respond. You are currently number 0 in the queue. You should be connected to an agent in approximately TIMEUID.. You are now chatting with AGENTUID 0 ID67 Optimus MEMORYUID Hi there! Welcome to Optimus prime Web Chat. How can I help you today? 1 ID67 Optimus DATEUID I like to pay

2 GROUP BY WITH DISTINCT, SUM , COUNT: PHP MySQL

一个人想着一个人 提交于 2020-01-07 06:57:15
问题 Ref : GROUP BY WITH HAVING ( DISTINCT ) : PHP , MYSQL I got answer (thanks @coytech) but I need one more column in it: as per: id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 I got answer Select mid , COUNT(distinct pid) as cpid , SUM(nwgh) as totalnwgh from test GROUP BY mid sqlfiddle : http://sqlfiddle.com/#!9/45e68/2 mid cpid totalnwgh 3 4 3.8 4 2 2.2 But above I need one more column that's as below :