count

Lex : print line numbers

Hello, I have a source code and I would like to add line numbers. What I've done : %{ int lines=0; %} LINE \n %% {LINE} {ECHO;printf("%d", ++lines);} However, I don't know how to catch the first line. Can you help me ? ...

Unordered List size scroll question

I have an UL with a lot of List items in it, I made a custom scroll to animate the DIV box so that you can see all the list items, i was the make an if else statement that says if your at the top you cant scroll past it and if you dont need to scroll to see anymore LI you cant go down any further. ...

COUNT(*) from multiple tables in MySQL

How do I go about selecting COUNT(*)s from multiple tables in MySQL? Such as: SELECT COUNT(*) AS table1Count FROM table1 WHERE someCondition JOIN?? SELECT COUNT(*) AS table2Count FROM table2 WHERE someCondition CROSS JOIN? subqueries? SELECT COUNT(*) AS table3Count FROM table3 WHERE someCondition Edit: The goal is to return this: ...

pivot table: getting data from one column

lets say my table like: Date Status 2010-01-02 2010-01-03 accept 2010-01-03 accept 2010-01-03 reject 2010-01-03 2010-01-04 reject i want if value null, it means accept. Beside that i want show the result like: Date Accept Reject 201...

COUNT results from SQL Query with a HAVING clause

Are you able to use COUNT in a query with a HAVING clause so that the COUNT returns the number of rows? When I try, Im getting the count of the number of times the ID shows up in the table. Here is the query: SELECT col_appid, min(col_payment_issued_date) as PayDate FROM tbl_ui_paymentstubs WHERE isnull(col_payment_amount,0) > 0...

Count number of users from a certain country

Hi everybody, I have a table of users, and in this table I have a country field telling where these people are from (i.e. "Sweden", "Italy", ...). How can I do a SQL query to get something like: Country Number Sweden 10 Italy 50 ... ... Users select their countries from a list I give to them, but the list is re...

jquery counting function. if statement

I am trying to write a bit of jquery to: if there is only one instance of the div which has a class of "option" take the href attribute and redirect to that href, this is what i have to far <script type="text/javascript"> var count =('Size: ' + $('.option').size()); if (count = 1) { $('.readmore a').each(function () { v...

MySQL order by COUNT DISTINCT

Hello I have a sql table: 2.8.7 2.8.3 2.8.2 2.8.7 2.8.5 2.8.7 2.8.7 2.8.5 2.6.0 2.8.3 2.6.4 2.6.3 2.8.4 2.8.0 2.6.3 2.8.5 2.8.5 2.8.5 2.6.0 2.8.2 How do I bring a unique value version sorted by the number of these versions? At the exit I want to get the following: 2.8.5 5 2.8.7 4 2.6.0 2 2.6.3 2 2.8.2 2 2.8....

display the mysql count function?

$query = "select count(*) from relationships where leader = 'user_id'"; $result = mysql_query($query); how can i display the count? thanks ...

SQL query to obtain a count of how many items have each possible value for a given column

Okay, so I have a (SQLite) table called log wherein one column (time) is a Unix epoch timestamp (the other columns are irrelevant for my purposes). These are timestamped log entries. I am trying to get a count of how many items are logged per hour (all-time -- I don't care to do it only for a given day or whatever; I'm trying to get an ...

More efficient way to COUNT() MYSQL rows via PHP?

Here is how I am currently counting mysql rows in PHP: //GET total # of results and build $start and $end for main SQL statement $sql= 'SELECT COUNT(*) FROM savedsearches WHERE user_id=\''.mysql_real_escape_string($user_id).'\''; $initial_query = mysql_query($sql) or die("SQL error"); $num_sql = mysql_fetch_array($initial_query); $numro...

counting non-zero elements within each row and within each column of a 2D numpy array

I have a numpy matrix that contains mostly nonzero values, but that occasionally will contain a zero value. I need to be able to: 1.) count the non-zero values in each row, and put that count into a variable that I can use in subsequent operations, perhaps by iterating through row indices and performing the calculations during the itera...

selecting id and count(id) from table in mysql

Hi guys, I am trying to make a photo album system in php and mysql. I have this code for list all photo albums: SELECT albums.*, count(pictures.id) AS countpic FROM albums LEFT JOIN pictures ON (albums.id=pictures.album_id) GROUP BY albums.id ORDER BY albums.date DESC"); I want to list title of photo albums with photo thumbnails ...

mysql where count(column_name) = 1?

Hi there, Here is the query I am using: SELECT k_id, COUNT(k_id) AS k_count FROM template_keyword_link WHERE k_id IN(1,2,3,4,5) GROUP BY k_id; This query returns something like 1 | 6 2 | 1 3 | 4 4 | 1 5 | 9 I want to add something like AND COUNT(k_id) = 1 so I end up with 2 | 1 4 | 1 However I get invalid use a group function...

counting null data in MySQL

let say i have one table, which have data like: name status bob single bob single jane null tina null shane married i want if status "single or data null" it means single. so if data empty script can read it as single and can count together. so i can show result like: Single Married 3 ...

Multiple conditional counts on one field in SQL

I have two tables where one contains author deatils and the other article details. One author may have many articles. In the article table is a field entitled "Decision" The decision field can be "Accepted" or "Rejected". I want a query to output a table of author name and ID followed by a count of their number of submissions, accepts a...

How can I get SQL statement created by ActiveRecord#find without actually executing it?

I am using will_paginate with some complicated queries and it is unable to correctly calculate number of total records (in order to display proper number of page links) - namely because of grouping by multiple columns. So, I am intending to get the SELECT query which would be used to retrieve ALL records, without actually executing it, ...

How to count the number of operations in a loop and give a theta characterization

I just want to make sure if I am doing this correct. I am trying to count the number of operations performed for the worst case scenario in java int sum = 0; for (int i = 0; i < n; i++ ) sum++; Is the number of operations 2+3n or 3+3n? I got the answer from counting int sum = 0 and int i = 0 for the "2" and i < n, i++, and su...

count concatenate column in mysql

I want do like this, but for another case that not function. This is my example table: Date Model No Line Range Lot Status 2010-08-01 KD-G435 1 01 1-100 013A accept 2010-08-01 KD-G435 2 01 1-100 013A accept 2010-08-01 KW-TC800 ...

my sql field sum using another field to diffrentiate and then sort it

hi again every one i would like to ask something about query using mysql i have this table called video_stat, and here's the field CREATE TABLE IF NOT EXISTS `video_stat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `video_id` int(10) NOT NULL, `member_id` int(10) NOT NULL, `counter` int(11) NOT NULL, `daydate` varchar(15) NOT NU...