count

Single MySQL query with count and sum

Hi there I have an SQL table that looks like this: CREATE TABLE IF NOT EXISTS `designerswave_article_visited` ( `article_visited_article_id` smallint(5) NOT NULL, `article_visited_user_id` smallint(5) NOT NULL, `article_user_rating` tinyint(1) DEFAULT NULL, UNIQUE KEY `article_id` (`article_visited_article_id`,`article_visited_...

MySQL: Counting most occurrences of a field's value

Given the following query, how do I return the p_name with the most transactions? And similarly, how do I return the t_amount with the most transactions. I'd like to do it all in this one query of course. SELECT t.*, p.* FROM transactions t LEFT JOIN partners p ON p.id=t.partner_id which can return something like: t_amount t_pla...

SQL COUNT of COUNT

I have some data I am querying. The table is composed of two columns - a unique ID, and a value. I would like to count the number of times each unique value appears (which can easily be done with a COUNT and GROUP BY), but I then want to be able to count that. So, I would like to see how many items appear twice, three times, etc. So for...

LINQ: Count number of true booleans in multiple columns

I'm using LINQ to SQL to speed up delivery of a project, which it's really helping with. However I'm struggling with a few things I'm used to doing with manual SQL. I have a LINQ collection containing three columns, each containing a boolean value representing whether an e-mail, mobile or address is availble. I want to write a LINQ que...

linq2nhibernate group by and orderby count() getting null reference

Hello, I'm trying to execute this linq2nhibernate query: from e in endContratoRepository.GetAll() where e.Contrato.idContrato == contrato.idContrato && e.Volume.idVolume == contratoVolume.Volume.idVolume && ...

PHP: Count values of array

I know the function count() of php, but what's the function for counting how often a value appear in an array? Example: $array = array( [0] => 'Test', [1] => 'Tutorial', [2] => 'Video', [3] => 'Test', [4] => 'Test' ); Now I want to count how often "Test" appears. ...

MySQL Query to Count Unique Domains from Email Address field

I'd like to get a better idea of what domains my customers are using. I could easily do this in PHP by explodeing each address and counting the domain that way. But I'm wondering if there's a way to get this information with just a plain MySQL query? This is what sample output would look like: gmail.com | 3942 yahoo.com | 3852 hotmai...

Finding folders

Hello. I want to find how much folders are in folder or I should say how much SubFolreds are in folder. So, how I should do that??? P.S. I'm programing with Delphi ...

Quarter as a Count variable in SAS.

Hye Guys, I'm busy working on a time series and am trying to find the commands that allow me to insert a quarter count variable. To keep things simple, the third quarter of 1995 (date my observations start) should be quarter -2, the fourth quarter of 1995 should be -1 etc etc uptill 2006 (should be somewhere around 45 by then). My dates...

counting employee attendance

I am trying to write a statement for counting the employees attendance and execute their id , name and the days that he has working on the last 3 months by counting the duplicate id on NewTimeAttendance for month 1, 2 and 3. I tried to count: Select COUNT(employeeid) from NewTimeAttendance where employeeid=1 and (month=1 or month =...

SSRS 2005 Matrix Reports - Editing Total

This seems as though it should be simple, but appears not to be. In SSRS 2005 I've written a matrix report and added some fields, one of which has the formula: If (x / y >= n, 1, 0). I've called this field 'Accuracy'. The report aggregates this field across a number of individuals and then for a number of days. Ideally I want a su...

Counting comma seperated values in php,how to?

Hey folks, I have a variable holding values separated by a comma (Implode), I'm trying to get the total count of the values in that variable however, count() is just returning 1. I've tried converting the comma separated values to a properly formatted array which still spits out1. So heres the quick snippet where the sarray session...

How can I use two or more COUNT()s in one SELECT statament?

i develop this code: SELECT COUNT(NewEmployee.EmployeeID), NewEmployee.EmployeeId,EmployeeName FROM NewEmployee INNER JOIN NewTimeAttendance ON NewEmployee.EmployeeID = NewTimeAttendance.EmployeeID and NewTimeAttendance.TotalTime is null and (NewTimeAttendance.note = '' or NewTimeAttendance.note is null) and (month = 1 or ...

Doctrine: Select elements that are related to one or more items in many-to-many relation

I have a category system that is related many-to-many with posts. How can I select a list of those categories that are related to one or more posts? $q = Doctrine_Query::create() ->from('Category c') ->where('<DONT KNOW WHAT TO WRITE>') ->select('c.name'); ...

LINQ SELECT COUNT(*) AND EmployeeId

Hi, I have a table like below: EmployeeId EmployeeName RequestId RequestName EmployeeId RequestId I need to a to assign requests in a sequential fashion(those who has mininum number of requests). Can I know how to get employee who has minimum requests using linq??? Thanks, Mahesh ...

Django queries: Count number of objects with FK to model instance

This should be easy but for some reason I'm having trouble finding it. I have the following: App(models.Model): ... Release(models.Model): date = models.DateTimeField() App = models.ForeignKey(App) ... How can I query for all App objects that have at least one Release? I started typing: App.objects.all().annotate(re...

MySQL: Getting "busiest" or "most popular" hour from a datetime field?

Consider the following table which has the fields - id (int) and date_created (datetime): id date_created 1 2010-02-25 12:25:32 2 2010-02-26 13:40:37 3 2010-03-01 12:02:22 4 2010-03-01 12:10:23 5 2010-03-02 10:10:09 6 2010-03-03 12:45:03 I want to know the busiest/most popular hour of t...

Count Clicks in excel

Hi, Can some one recommend any free program which counts the number of clicks Clicked inside a cell. For Example Imagine something like Spreadsheet I click on A1 cell the value shows 1 Then I click A1 cell again the value shows 2 and so on If I click A3 cell somewhere in between the click count on Cell A3 shows 1 and so on If someth...

GDI handles in a DotNET application

My pure DotNET library runs as a plugin inside an unmanaged desktop application. I've been getting a steady (though low) stream of crash reports that seem to indicate a problem with GDI handles (fonts in error messages etc. revert to the system font, display of all sorts of controls break down, massive crash shortly after). My Forms hav...

Python - retrieving info from a syslog file

I have been asked to write a program using python for an assignment. I have been given a syslog file and I have to find things out about it How do I find out how many attempts were made to login to the root account? Any advice would be highly appreciated as I am very new to python and completely lost! ...