count

Count On Condition in same column

允我心安 提交于 2020-01-07 06:39:25
问题 After searching a lot, I have to ask experts here... Table 1 (attendance) att_id att_date class_id student_id att_status 1 07-11-2013 1 1 P 2 07-11-2013 1 2 L 3 07-11-2013 1 3 P 4 07-11-2013 1 4 P 5 08-11-2013 2 5 P 6 08-11-2013 2 6 P 7 08-11-2013 2 7 A 8 08-11-2013 2 8 P 9 09-11-2013 1 1 L 10 09-11-2013 1 2 P 11 09-11-2013 1 3 A 12 09-11-2013 1 4 P 13 09-11-2013 2 5 P Where in att_status P=Present, A=Absence, L=Leave. Now I want to count individual student Present, Absent and Leave based on

CodeIgniter - order my 'posts' by month?

…衆ロ難τιáo~ 提交于 2020-01-07 05:05:33
问题 In my website I'd like to create an 'archive' list to categorise my posts. My posts table is set up like so: id | post_title | post | pubdate | year | month Currently this model function pulls the posts: function getNews(){ $data = array(); $this->db->order_by("id", "desc"); $Q = $this->db->get('posts'); if ($Q->num_rows() > 0){ foreach ($Q->result_array() as $row){ $data[] = $row; } } $Q->free_result(); return $data; } However, is it possible I can create a list like the following? July (12)

SQL using COUNT and CASE for related table - error is returned

故事扮演 提交于 2020-01-07 04:55:08
问题 I have table T1: ID GROUPINFO STATUS 1 GROUP1 NEW 2 GROUP1 INPROG 3 GROUP2 INPROG I have table T2 also T2ID T1ID STATUS 1 1 NEW 2 2 NEW 3 2 VENDOR 4 3 NEW 5 3 VENDOR I want to count by group how many of those records have the status NEW, and how many of those records were in the status VENDOR (information from T2 table) This SQL works SELECT T1.GROUPINFO, count (case when T1.status='NEW' then 1 end) as New FROM T1 GROUP BY T1.GROUPINFO However when I try to add how many of those records were

Counting the number of wins for teams in a nested list

帅比萌擦擦* 提交于 2020-01-07 04:23:30
问题 I have written some code that I'm trying to use in order to calculate how many times a football team have won a match. The matches are placed into a nested list where each sub list contains the names of two teams and their scores for the game respectively. L = [['Patriots', 'Giants', '3', '1'], ['Steelers', 'Patriots', '1', 2'], ['Giants', 'Steelers', '3', '5']] However the list is much larger and contains more football teams who played in matches. I already have a final List which contains

Watir webdriver; counting elements with changing class names

早过忘川 提交于 2020-01-07 02:11:11
问题 I am using Rspec and Watir-webdriver and am looking to get a count of all the elements that have been clicked. What I'm doing: I perform a search and get back a list of results; I then run a loop to select only 5 of them. The class name for these elements goes from asset-card selectable to now saying asset-card selectable selected . I try to get a proper count by doing this: count = @browser.elements(:class, 'selected').size But this is still giving me all results and not specifically the

MySQL Find previous date that a song was played

会有一股神秘感。 提交于 2020-01-07 02:02:46
问题 I'm looking for any help to why my code here isn't working anymore. SQL Fiddle links for the ORIGINAL and MODIFIED code. I had my database in two different tables and this code worked fine. SELECT DATE_FORMAT(a.show_date,'%m/%d/%y') as show_date, a.song_order, a.show_id, b.song_name, a.song_id, ( SELECT IFNULL(MAX(DATE_FORMAT(show_date,'%m/%d/%y')), 'NEW SONG') FROM tbl_shows AS c WHERE a.show_date > c.show_date and a.song_id = c.song_id ) As PrevDate FROM tbl_shows a, tbl_songs b WHERE a

Selected event not raised for ObjectDatasource when enable-caching is true

不想你离开。 提交于 2020-01-06 17:29:11
问题 I've a Gridview control using an ODS(ObjectDataSource) to fetch data. For the best performance and efficiency, I've turned-off the view state of Gridview (i.e. EnableViewstate = "false". And I've also enabled caching in the associated Objectdatasource. This eliminates as much as 50-60% performance optimization because it eliminates the DB round-trip .. courtesy ODS Caching. So, after this I got stuck into the famous "ODS sorting" issue but I managed to invent a tricky solution for it and its

Saving the click counts of an item each item it is clicked

China☆狼群 提交于 2020-01-06 16:10:45
问题 Currently I try to build up a like counter for my web page. Below you can see the click counter. It's fully working. Sadly (but for sure) just for the current session... Is there any possibility to store the value forever? One last thing! On the website is more than one picture to like. So I have no Idea how to store the values using cookies or localstorage. Maybe you have another Idea? Maybe no JS? var currentValue = 0, count = $('.count'); $(document).ready(function() { count.each(function

Query that Counts records with a WHERE clause

戏子无情 提交于 2020-01-06 15:31:26
问题 SELECT EmailOfConsumer, COUNT(EmailOfConsumer) as 'NumberOfOrders', SUM(CAST(Total as money)) as 'TotalValue', (SUM(CAST(Total as money))/COUNT(EmailOfConsumer)) as 'AverageValue' FROM webshop GROUP BY EmailOfConsumer ORDER BY TotalValue DESC This brings back: EmailOfConsumer NumberOfOrders TotalValue AverageValue test 1 2000000000.10 2000000000.10 I would like to add a search on WHERE NumberOfOrders = '1' I have tried adding WHERE COUNT(EmailOfConsumer) = '1' but I get this error: An

Ruby 1.92 in Rails 3: A Case where Array.length Does Not Equal Array.count?

拜拜、爱过 提交于 2020-01-06 14:17:14
问题 My understanding is that count and length should return the same number for Ruby arrays. So I can't figure out what is going on here (FactoryGirl is set to create--save to database--by default): f = Factory(:family) # Also creates one dependent member f.members.count # => 1 f.members.length # => 1 m = Factory(:member, :family=>f, :first_name=>'Sam') #Create a 2nd family member f.members.count # => 2 f.members.length # => 1 puts f.members # prints a single member, the one created in the first