Search Results

Search found 11153 results on 447 pages for 'count zero'.

Page 21/447 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Linq join with COUNT

    - by shivesh
    I have 2 tables, Forums and Posts. I want to retrieve all Forums fields with a new extra field: count all post that belong to this forum. I have this for now: var v =(from forum in Forums join post in Posts on forum.ForumID equals post.Forum.ForumID select new { forum, //Need to retrieve all fields/columns from forum PostCount = //count all post that belong to this forum with a condition: count it only if post.Showit==1 } ).Distinct() The join must be Left join: if there are no post that belongs to some forum, the forums fields should be retrieved but PostCount field should be 0. The result set must be distinct (join gives me the full cross...or how it's called)

    Read the article

  • Saving a select count(*) value to an integer (SQL Server)

    - by larryq
    Hi everyone, I'm having some trouble with this statement, owing no doubt to my ignorance of what is returned from this select statement: declare @myInt as INT set @myInt = (select COUNT(*) from myTable as count) if(@myInt <> 0) begin print 'there's something in the table' end There are records in myTable, but when I run the code above the print statement is never run. Further checks show that myInt is in fact zero after the assignment above. I'm sure I'm missing something, but I assumed that a select count would return a scalar that I could use above?

    Read the article

  • Linq Paging - How to incorporate total record count

    - by Billy Logan
    Hello everyone, I am trying to figure out the best way of getting the record count will incorporating paging. I need this value to figure out the total page count given a page size and a few other variables. This is what i have so far which takes in the starting row and the page size using the skip and take statements. promotionInfo = (from p in matches orderby p.PROMOTION_NM descending select p).Skip(startRow).Take(pageSize).ToList(); I know i could run another query, but figured there may be another way of achieving this count without having to run the query twice. Thanks in advance, Billy

    Read the article

  • sql: can i do a max(count(*)) ?

    - by every_answer_gets_a_point
    here's my code: select yr,count(*) from movie join casting on casting.movieid=movie.id join actor on casting.actorid = actor.id where actor.name = 'John Travolta' group by yr here's the question Which were the busiest years for 'John Travolta'. Show the number of movies he made for each year. here's the table structure movie(id, title, yr, score, votes, director) actor(id, name) casting(movieid, actorid, ord) this is the output i am getting: yr count(*) 1976 1 1977 1 1978 1 1981 1 1994 1 etcetc i need to get the rows for which count(*) is max how do i do this?

    Read the article

  • C - array count, strtok, etc

    - by Pedro
    Hi... i have a little problem on my code... HI open a txt that have this: LEI;7671;Maria Albertina da silva;[email protected]; 9;8;12;9;12;11;6;15;7;11; LTCGM;6567;Artur Pereira Ribeiro;[email protected]; 6;13;14;12;11;16;14; LEI;7701;Ana Maria Carvalho;[email protected]; 8;13;11;7;14;12;11;16;14; LEI, LTCGM are the college; 7671, 6567, 7701 is student number; Maria, Artur e Ana are the students name; [email protected], ...@gmail are emails from students; the first number of every line is the total of classes that students have; after that is students school notes; example: College: LEI Number: 7671 Name: Maria Albertina da Silva email: [email protected] total of classes: 9 Classe Notes: 8 12 9 12 11 6 15 7 11. My code: typedef struct aluno{ char sigla[5];//college char numero[80];//number char nome[80];//student name char email[20];//email int total_notas;// total of classes char tot_not[40]; // total classes char notas[20];// classe notes int nota; //class notes char situacao[80]; //situation (aproved or disaproved) }ALUNO; void ordena(ALUNO*alunos, int tam)//bubble sort { int i=0; int j=0; char temp[100]; for( i=0;i<tam;i++) for(j=0;j<tam-1;j++) if(strcmp( alunos[i].sigla[j], alunos[i].sigla[j+1])>0){ strcpy(temp, alunos[i].sigla[j]); strcpy(alunos[i].sigla[j],alunos[i].sigla[j+1]); strcpy(alunos[i].sigla[j+1], temp); } } void xml(ALUNO*alunos, int tam){ FILE *fp; char linha[60];//line int soma, max, min, count;//biggest note and lowest note and students per course count float media; //media of notes fp=fopen("example.txt","r"); if(fp==NULL){ exit(1); } else{ while(!(feof(fp))){ soma=0; media=0; max=0; min=0; count=0; fgets(linha,60,fp); if(linha[0]=='L'){ if(ap_dados=strtok(linha,";")){ strcpy(alunos[i].sigla,ap_dados);//copy to struct // i need to call bubble sort here, but i don't know how printf("College: %s\n",alunos[i].sigla); if(ap_dados=strtok(NULL,";")){ strcpy(alunos[i].numero,ap_dados);//copy to struct printf("number: %s\n",alunos[i].numero); if(ap_dados=strtok(NULL,";")){ strcpy(alunos[i].nome, ap_dados);//copy to struct printf("name: %s\n",alunos[i].nome); if(ap_dados=strtok(NULL,";")){ strcpy(alunos[i].email, ap_dados);//copy to struct printf("email: %s\n",alunos[i].email); } } } }i++; } if(isdigit(linha[0])){ if(info_notas=strtok(linha,";")){ strcpy(alunos[i].tot_not,info_notas); alunos[i].total_notas=atoi(alunos[i].tot_not);//total classes for(z=0;z<=alunos[i].total_notas;z++){ if(info_notas=strtok(NULL,";")){ strcpy(alunos[i].notas,info_notas); alunos[i].nota=atoi(alunos[i].notas); // student class notes } soma=soma + alunos[i].nota; media=soma/alunos[i].total_notas;//doesn't work if(alunos[i].nota>max){ max=alunos[i].nota;;//doesn't work } else{ if(min<alunos[i].nota){ min=alunos[i].nota;;//doesn't work } } //now i need to count the numbers of students in the same college, but doesn't work /*If(strcmp(alunos[i].sigla, alunos[i+1].sigla)=0){ count ++; printf("%d\n", count); here for LEI should appear 2 students and for LTCGM appear 1, don't work }*/ //Now i need to see if student is aproved or disaproved // Student is disaproved if he gets 3 notes under 10, how can i do that? } printf("media %d\n",media); //media printf("Nota maxima %d\n",max);// biggest note printf("Nota minima %d\n",min); //lowest note }i++; } } } fclose(fp); } int main(int argc, char *argv[]){ ALUNO alunos; FILE *fp; int tam; fp=fopen(nomeFicheiro,"r"); alunos = (ALUNO*) calloc (tam, sizeof(ALUNO)); xml(alunos,nomeFicheiro, tam); system("PAUSE"); return 0; }

    Read the article

  • Select count() max() Date

    - by DAVID
    I have a table with shifts history along with emp ids. I'm using this query to retrieve a list of employees and their total shifts by specifying the range to count from: SELECT ope_id, count(ope_id) FROM operator_shift WHERE ope_shift_date >=to_date( '01-MAR-10','dd-mon-yy') and ope_shift_date <= to_date('31-MAR-10','dd-mon-yy') GROUP BY OPE_ID which gives OPE_ID COUNT(OPE_ID) 1 14 2 7 3 6 4 6 5 2 6 5 7 2 8 1 9 2 10 4 10 rows selected. How do I choose the employee with the highest number of shifts under the specified range date?

    Read the article

  • count clicks using actionscript 3.0 in flash

    - by Michael Stone
    I want to change the variable value based on the number of clicks. So if you click the button once, the cCount should equal 1 and twice it should equal 2. Right now all I'm returning for the value is 0, no matter the amount of clicks. Any ideas? btnRaw.addEventListener(MouseEvent.CLICK, flip); btnRaw.addEventListener(MouseEvent.MOUSE_UP,count); //create the flipping function //create the variable to store the click count var cCount:Number = 0; function flip(Event:MouseEvent):void{ raw_patty_mc.gotoAndPlay(1); } function count(Event:MouseEvent):void{ cCount = cCount+1; if(cCount>3 || cCount<6){ titleText.text="See you're doing a great job at flipping the burger! "+String(cCount); } }

    Read the article

  • SQL where clause to work with Group by clause after performing a count()

    - by Matt
    Tried my usual references at w3schools and google. No luck I'm trying to produce the following results. QTY is a derived column | Position | QTY -------------------- 1 Clerk 2 2 Mgr 2 Here's what I'm not having luck with: SELECT Position, Count(position) AS 'QTY' FROM tblemployee Where ('QTY' != 1) GROUP BY Position I know that my Position is set up as varchar(255) Count produces a integer data and my where clasue is accurate so that leads me to believe that that Count() is jamming me up. Please throw up an example so I can reference later. Thanks for the help!

    Read the article

  • Help with SQL query (list strings and count in same query)

    - by Mestika
    Hi everybody, I’m working on a small kind of log system to a webpage, and I’m having some difficulties with a query I want to do multiple things. I have tried to do some nested / subqueries but can’t seem to get it right. I’ve two tables: User = {userid: int, username} Registered = {userid: int, favoriteid: int} What I need is a query to list all the userid’s and the usernames of each user. In addition, I also need to count the total number of favoriteid’s the user is registered with. A user who is not registered for any favorite must also be listed, but with the favorite count shown as zero. I hope that I have explained my request probably but otherwise please write back so I can elaborate. By the way, the query I’ve tried with look like this: SELECT user.userid, user.username FROM user,registered WHERE user.userid = registered.userid(SELECT COUNT(favoriteid) FROM registered) However, it doesn’t do the trick, unfortunately Kind regards Mestika

    Read the article

  • Django: query with ManyToManyField count?

    - by AP257
    In Django, how do I construct a COUNT query for a ManyToManyField? My models are as follows, and I want to get all the people whose name starts with A and who are the lord or overlord of at least one Place, and order the results by name. class Manor(models.Model): lord = models.ManyToManyField(Person, null=True, related_name="lord") overlord = models.ManyToManyField(Person, null=True, related_name="overlord") class Person(models.Model): name = models.CharField(max_length=100) So my query should look something like this... but how do I construct the third line? people = Person.objects.filter( Q(name__istartswith='a'), Q(lord.count > 0) | Q(overlord.count > 0) # pseudocode ).order_by('name'))

    Read the article

  • Select count / duplicates

    - by mike
    Hello! I have a table with all U.S. zip codes. each row contains the city and state name for the zip code. I'm trying to get a list of cities that show up in multiple states. This wouldn't be a problem if there weren't X amount of zip codes in the same city... So basically, I just want to the city in a state to count as 1 instead of it counting the city/state 7 times because there are 2+ zip codes in that city/state... I'm not really sure how to do this. I know I need to use count but how do I tell the mysql to only count a given city/state combo as 1?

    Read the article

  • tchar safe functions -- count parameter for UTF-8 constants

    - by Dustin Getz
    I'm porting a library from char to TCHAR. the count parameter of this fragment, according to MSDN, is the number of multibyte characters, not the number of bytes. so, did I get this right? _tcsncmp(access, TEXT("ftp"), 3); //or do i want _tcsnccmp? "Supported on Windows platforms only, _mbsncmp and _mbsnbcmp are multibyte versions of strncmp. _mbsncmp will compare at most count multibyte characters and _mbsnbcmp will compare at most count bytes. They both use the current multibyte code page. _tcsnccmp and _tcsncmp are the corresponding Generic functions for _mbsncmp and _mbsnbcmp, respectively. _tccmp is equivalent to _tcsnccmp."

    Read the article

  • max count with joins

    - by trixet
    I have 3 tables: users: Id Login 1 John 2 Bill 3 Jim computers: Id Name 1 Computer1 2 Computer2 3 Computer3 4 Computer4 5 Computer5 sessions: UserId ComputerId Minutes 1 2 47 2 1 32 1 4 15 2 5 5 1 2 7 1 1 40 2 5 31 I would like to display this resulting table: Login Total_sess Total_min Most_freq_computer Sess_on_most_freq Min_on_most_freq John 4 109 Computer2 2 54 Bill 3 68 Computer5 2 36 Jim - - - - - Myself I can only cover first 3 columns with: SELECT Login, COUNT(sessions.UserId), SUM(Minutes) FROM users LEFT JOIN sessions ON users.Id = sessions.UserId GROUP BY users.Id And some kind of other columns with: SELECT main.* FROM (SELECT UserId, ComputerId, COUNT(*) AS cnt ,SUM(Minutes) FROM sessions GROUP BY UserId, ComputerId) AS main INNER JOIN ( SELECT ComputerId, MAX(cnt) AS maxCnt FROM ( SELECT ComputerId, UserId, COUNT(*) AS cnt FROM sessions GROUP BY ComputerId, UserId ) AS Counts GROUP BY ComputerId) AS maxes ON main.ComputerId = maxes.ComputerId AND main.cnt = maxes.maxCnt But I need to get whole resulting table in one query. I feel I'm doing something completely wrong. Need help.

    Read the article

  • Counting divs for pagination in Jquery

    - by Craig Ward
    I want to create a nice pagination in Jquery for a number of divs I have. EG: <div class="container"> <div id="one">content</div> <div id="two">content</div> <div id="three">content</div> <div id="four">content</div> </div> The number will not always be the same so I need to count the divs, and display a pagination like the one below. 1|2|3|4 Clicking on the page number would display the relevant div. I know how to show and hide elements using Jquery and css and have figured out I can count the divs using var numPages = $('.container').size(); but I can't work out how I can display the pagination. Any pointers?

    Read the article

  • Jquery counting elements by class what is the best way to implement this?

    - by 133794m3r
    Ok what i'm trying to do is to count all of the elements in the current page with the same class and then i'm going to use it to be added onto a name for a input form. Basically i'm allowing users to click on an and then by doing so add another one for more of the same type of items. But i can't think of a way to count all of these simply with jquery/javascript. I was going to then name the item as something like name="whatever(total+1)", if anyone has a simple way to do this i'd be extremely grateful as javascript isn't exactly my native tongue and stack overflow usually has a ton of great answers and a great community so i'm hoping my query will not go unheard.

    Read the article

  • how to get count column

    - by soclose
    Hi I'd like to get the value of Count column from cursor. public Cursor getRCount(String iplace) throws SQLException { try { String strSql = "SELECT COUNT(_id) AS RCount FROM tbName WHERE place= '" + iplace + "'"; return db.rawQuery(strSql, null); } catch (SQLException e) { Log.e("Exception on query", e.toString()); return null; } } I tried to get this count column value from cursor like below Cursor cR = mDbHelper.getRCount(cplace);if (cR.getCount() > 0){long lCount = cR.getLong(0);}cR.close();} I got the debug error. How to get it?

    Read the article

  • Group and count in Rails

    - by alamodey
    I have this bit of code and I get an empty object. @results = PollRoles.find( :all, :select => 'option_id, count(*) count', :group => 'option_id', :conditions => ["poll_id = ?", @poll.id]) Is this the correct way of writing the query? I want a collection of records that have an option id and the number of times that option id is found in the PollRoles model. EDIT: This is how I''m iterating through the results: <% @results.each do |result| %> <% @option = Option.find_by_id(result.option_id) %> <%= @option.question %> <%= result.count %> <% end %>

    Read the article

  • C# Count registry keys existing using a partial value

    - by cheeseman
    Microsoft.Win32.RegistryKey registryPath = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Testing"); Microsoft.Win32.RegistryKey entryKey = registryPath.OpenSubKey("Entry Point"); I have a lot of keys in Testing, in the format: "Entry Point 011", "Entry Point 123" - so Entry Point with random numbers after it. Would I be able to search the registryPath variable above and get a count of the number of keys containing the "Entry Point" keyword? Assuming that there are also other keys existing without this keyword. At the moment I have been using a for loop and looping for all possible combinations to get a count of all the keys, checking if the key exists or not, but as there are keys as high as "Entry Point 9000" having a for loop execute 9000 times is very inefficient. for (int i = 0; i <= highestEntryPointValue; i++) { Microsoft.Win32.RegistryKey entryKey = steamApps64.OpenSubKey("Entry Point " + Convert.ToString(i)); if (entryKey != null) { count++; } }

    Read the article

  • Nested loop with dependent bounds trip count

    - by aaa
    hello. just out of curiosity I tried to do the following, which turned out to be not so obvious to me; Suppose I have nested loops with runtime bounds, for example: t = 0 // trip count for l in 0:N for k in 0:N for j in max(l,k):N for i in k:j+1 t += 1 t is loop trip count is there a general algorithm/way (better than N^4 obviously) to calculate loop trip count? I am working on the assumption that the iteration bounds depend only on constant or previous loop variables.

    Read the article

  • Getting count() of class static array

    - by xylar
    Is it possible to get the count of a class defined static array? For example: class Model_Example { const VALUE_1 = 1; const VALUE_2 = 2; const VALUE_3 = 3; public static $value_array = array( self::VALUE_1 => 'boing', self::VALUE_2 => 'boingboing', self::VALUE_3 => 'boingboingboing', ); public function countit() { // count number $total = count(self::$value_array ); echo ': '; die($total); } } At the moment calling the countit() method returns :

    Read the article

  • SQL where clasue to work with Group by clasue after performing a count()

    - by Matt
    Tried my usual references at w3schools and google. No luck I'm trying to produce the following results. QTY is a derived column | Position | QTY -------------------- 1 Clerk 2 2 Mgr 2 Here's what I'm not having luck with: SELECT Position, Count(position) AS 'QTY' FROM tblemployee Where ('QTY' != 1) GROUP BY Position I know that my Position is set up as varchar(255) Count produces a integer data and my where clasue is accurate so that leads me to believe that that Count() is jamming me up. Please throw up an example so I can reference later. Thanks for the help!

    Read the article

  • Counting variables per observation per month in Sas.

    - by John
    Hey guys, a quick question, I have data of the following sort: Ticker _ Date _ Fem Analyst (dummy 1 if true) AA _ 04/2001 _ 1 AA _ 04/2001 _ 1 AA _ 04/2001 _ 1 AA _ 05/2002 _ 1 AA _ 05/2002 _ 1 AA _ 07/2002 _ 0 AA _ 04/2003 _ 1 and so on.. What I want to receive is the following: Ticker _ Date _ Number of fem analyst AA _ 04/2001 _ 3 AA _ 05/2002 _ 2 AA _ 07/2002 _ 0 AA _ 04/2003 _ 1 So an easy counting algorithm that allows me to count for the number of analysts per company per month (the date is in 01/04/2002 format but I also have a month count variable which can be used too) Any ideas?

    Read the article

  • jquery text area length count?

    - by Nimesh
    Hi All, I have a text area field where i need to provide information about the word count when the user enters some text in the field. Length of the field is supposed to be 500 Characters. Initialy it must show min characters:100 | 0 of 500 // 0 of 500 must be in red color and once the user enters come character need to update the count as well. Once the user reaches the count say the min character 100, i need to display min characters:100 | 100 of 500 // 100 of 500 must be in green color. How can i do this?? is there any plugin for the same??? let me know your thoughts on this.

    Read the article

  • MySQL COUNT help

    - by space
    I'm trying to count all the ids form table3 that are related to the first two tables but I think my SQL code is wrong can some one help me fix it? Here is the code: $dbc = mysqli_query($mysqli,"SELECT table1.*, table2.*, COUNT(id) as num, table3.id FROM table1 INNER JOIN table2 ON table1.id = table2.id INNER JOIN table3 ON table2.id = table3.id WHERE table2.id = '$id'"); Here is the error message. Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >