Search Results

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

Page 18/447 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • count(*) is it really expensive ?

    - by Anil Namde
    I have a page where i have 4 tabs displaying 4 different reports based of different tables. Now i get row count of each tabled using select count() from table query and display number of rows available in each table on the tabs. Now with each page post back 5 count() queries are executed (4 to get counts and 1 for pagination) and 1 query for getting report. Now my question is should is count(*) query really expensive that i should keep the row counts (at least which are displayed on tab) in view state of page instead of queering each time? How much expensive it is ?

    Read the article

  • count subtitled grouping in excel please...

    - by total newbie
    Excel sheet is subtitled but need now to do a count of the items in each grouping so need to find subtilted rows by using a macro and count the number of items in each grouped section (column a) placing the count value in the relevant subtitled row in Column A. no idea where to start can anyone help. Running the subtilteld function again adds another row but i need all of this on the same row..

    Read the article

  • Is there a better way to find the max count in a table

    - by nXqd
    select NV.PHG From Nhanvien NV Group by NV.phg Having count(nv.Manv) >= all (select count(NV.MANV from nhanvien nv group by nv.MANV)) I'm finding a better way to find the 'max count' NV of a PHG ( in this example ) . I think, we meet this case all the time when we do SQL, i should've a better way . Thanks for reading this :)

    Read the article

  • Excel wizardness needed - Group By, Sort, Count function help

    - by Chris
    Riddle me this: You have 3 part numbers with the same part name xyz, each with a quantity of 10 items. The items can be picked during the day or week, therefore changing the amount of items on hand. I know I need to use the group by, sort, count and perhaps sumif formulas to have a running count of the number of items on hand at the end of each day (which could be positive or negative). Help? it wont let me add an image because i'm a new user. 'Oops! Your edit couldn't be submitted because: * we're sorry, but as a spam prevention mechanism, new users aren't allowed to post images. Earn more than 10 reputation to post images. '

    Read the article

  • how to create a subquery in sql using count based on outer query

    - by user1754716
    I hope someone can help me with this query. Basically I have two queries that I want to "combine". I want the second query as an extra column along with the first query. The first one is this : SELECT t_Item_Storage_Location.Storage_Loc_Nbr, t_Storage_Location.Storage_Loc_Type_Code, Count(t_Load.Load_Id) AS CurrentLoadCount, t_load.MMM_Id_Nbr FROM t_Load INNER JOIN (t_Storage_Location INNER JOIN t_Item_Storage_Location ON t_Storage_Location.Storage_Loc_Nbr = t_Item_Storage_Location.Storage_Loc_Nbr) ON (t_Load.Storage_Loc_Nbr = t_Item_Storage_Location.Storage_Loc_Nbr) AND (t_Load.MMM_Id_Nbr = t_Item_Storage_Location.MMM_Id_Nbr) where ((((t_Item_Storage_Location.MMM_Id_Nbr) Between '702004%' And '702011%') AND ((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%A') AND ((t_Storage_Location.Storage_Loc_Type_Code)='CD') AND ((t_Load.Active_Status_Ind)='A') AND ((t_Load.QC_Status_Code) Like 'R%') AND ((t_Load.MMM_Facility_Code)='MC')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%B')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%C')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%D')) OR (((t_Item_Storage_Location.Storage_Loc_Nbr) Like '%E')) ) GROUP BY t_Item_Storage_Location.MMM_Id_Nbr, t_Item_Storage_Location.Storage_Loc_Nbr, t_Storage_Location.Storage_Loc_Type_Code, t_Load.MMM_Facility_Code, t_load.MMM_Id_Nbr HAVING Count(t_Load.Load_Id)<4 The second one, is based on the t_load.MMM_Id_Nbr of the first one. Basically I want a count of all the loads with that mmm_id_nbr. SELECT count(Load_ID) as LoadCount, MMM_Id_Nbr, storage_Loc_Nbr FROM t_load WHERE QC_Status_Code like 'R%' and mmm_Facility_Code ='MC' and Active_Status_Ind='A' GROUP by MMM_Id_Nbr, storage_loc_Nbr

    Read the article

  • Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing

    - by Paresh
    I am getting the error from the application as following with SQL server 2005 "Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 1, current count = 0" How can i find the stage where this error raised? how can i found the missing transaction or the stored procedure where it is not committ or rollback?

    Read the article

  • Desimal data Type Display scale part as zero

    - by Wael Dalloul
    I have Decimal field in SQLserver 2005 table, Price decimal(18, 4) if I write 12 it will be converted to 12.0000, if I write 12.33 it will be converted into 12.3300. Always it's putting zero to the right of the decimal point in the count of Scale Part(4). I was using these in SQL Server 2000, it was not behaving like this, in SQL Server 2000 if I put 12.5 it will be stored as 12.5 not as 12.5000 what SQLServer2005 do. My Question is how to stop SQL Server 2005 from putting zeros to the right of the decimal point?

    Read the article

  • MySQL: Get only count of result set.

    - by Varun
    I am using MVC with PHP/MySQL. Suppose I am using 10 functions with different queries for fetching details from the database. But at other times I may want to get only the count of the result that will be returned by the query. What is the standard way to handle such situation. Should I write 10 more functions which duplicate almost whole query and return only the count. Or Should I always return the count also with the result set Or I can pass a flag to indicate that the function should return count only, and then based on the flag I will dynamically generate the (select part of) query. Or Is there a better way?

    Read the article

  • preg_match find multiple partial appearances of a word in a string

    - by Rubytastic
    Any regex gurus around here? its driving me crazy. Say I have this string: "bookstore books Booking" I want to count the number "books" appears in this and return the number. Currently I have this which is not working: $string = "bookstore books Booking"; if (preg_match_all('/\b[A-Z]+books\b/', $string, $matches)) { echo count($matches[0]) . " matches found"; } else { echo "match NOT found"; } On top of this the "books" inside the preg_match_all should become a $var Anyone an idea how to count correctly?

    Read the article

  • Regex expression with leading zero

    - by user1874087
    I'm rather new to regex expressions and need help with a simple expression. I'm using Pentaho for ETL (Replace in String transformation) and I have column values that I need to add leading zeros to and parse out text as part of the database import. So far I have been unable to add the leading zero. The column is called Region and the values are "region 8", "region 10", "region 11". My regex expression is ['Region'] which will eliminate the region text but produces results = "8", "10", "11". I need values to produce "08", "10", "11". So all the single digit numbers must have leading zeros.

    Read the article

  • Objective-C ref count and autorelease

    - by turbovince
    Hey guys, suppose the following code: int main (int argc, const char * argv[]) { //[...] Rectangle* myRect = [[Rectangle alloc] init]; Vector2* newOrigin = [[[Vector2 alloc] init] autorelease]; // ref count 1 [newOrigin setX: 50.0f]; [myRect setOrigin: newOrigin]; // ref count 2 [myRect.origin setXY: 25.0f :100.0f]; // ref count goes to 3... why ? [myRect release]; [pool drain]; return 0; } Rectangle's origin is declared as a (retain) synthesized property. Just wondering 2 things: Why does ref count goes to 3 when using the getter accessor of Rectangle's origin? Am I doing something wrong ? With a ref count of 3, I don't understand how this snippet of code cannot leak. Calling release on myRect will make it go down to 2 since I call release on the origin in dealloc(). But then, when does autorelease take effect? Thanks!

    Read the article

  • MySQL - Join as zero if record Not IN

    - by Zurahn
    To explain by example, take two tables, A and B Table A id foo 1 x 2 y 3 z Table B id aid bar 1 3 50 2 1 100 An example join SELECT foo, bar FROM a, b WHERE a.id = b.aid; Garners a result of foo bar z 50 x 100 What I would like to do is get all values of foo and for any instances where there isn't a corresponding bar value, return 0 for that column. My best guess was something along the lines of SELECT foo, bar AS br FROM a, b WHERE a.id = b.aid OR a.id NOT IN (SELECT aid FROM b); But that returns duplicates and non-zero values for bar. Possible?

    Read the article

  • Get the count of A -> B and B->A without duplicates

    - by TomGasson
    I have a table like so: index|from | to ------------------ 1 | ABC | DEF 2 | ABC | GHI 3 | ABC | GHI 4 | ABC | JKL 5 | ABC | JKL 6 | ABC | JKL 7 | DEF | ABC 8 | DEF | GHI 9 | DEF | JKL 10 | GHI | ABC 11 | GHI | ABC 12 | GHI | ABC 13 | JKL | DEF And I need to count how the total times between the points (regardless of direction) to get the result: A | B | count ----------------- ABC | DEF | 2 ABC | GHI | 5 ABC | JKL | 3 DEF | GHI | 1 DEF | JKL | 2 So far I can get: SELECT `a`.`from` as `A`, `a`.`to` as `B`, (`a`.`count` + `b`.`count`) as `count` FROM (SELECT `from`, `to`, count(*) as `count` FROM `table` GROUP BY 1,2) `a` LEFT OUTER JOIN (SELECT `from`,`to`, count(*) as `count` FROM `table` GROUP BY 1,2) `b` ON `a`.`from` = `b`.`to` AND `a`.`to` = `b`.`from` But I'm unsure how to remove the A/B swapped duplicates.

    Read the article

  • mysql count rows and grop them by month

    - by user2661296
    I have a table called cc_calls and there I have many call records I want to count them and group them in months I have a timestamp called starttime and I can use that row to extract the month, also limit the count for 12 months the results should be like: Month Count January 768768 February 876786 March 987979 April 765765 May 898797 June 876876 July 786575 August 765765 September 689787 October 765879 November 897989 December 876876 Can anyone guide me or show me the mysql query that I need to get this result.

    Read the article

  • Getting counts of 0 from a query with a double group by

    - by Maltiriel
    I'm trying to write a query that gets the counts for a table (call it item) categorized by two different things, call them type and code. What I'm hoping for as output is the following: Type Code Count 1 A 3 1 B 0 1 C 10 2 A 0 2 B 13 2 C 2 And so forth. Both type and code are found in lookup tables, and each item can have just one type but more than one code, so there's also a pivot (aka junction or join) table for the codes. I have a query that can get this result: Type Code Count 1 A 3 1 C 10 2 B 13 2 C 2 and it looks like (with join conditions omitted): SELECT typelookup.name, codelookup.name, COUNT(item.id) FROM typelookup LEFT OUTER JOIN item JOIN itemcodepivot RIGHT OUTER JOIN codelookup GROUP BY typelookup.name, codelookup.name Is there any way to alter this query to get the results I'm looking for? This is in MySQL, if that matters. I'm not actually sure this is possible all in one query, but if it is I'd really like to know how. Thanks for any ideas.

    Read the article

  • Sort string based upon the count of characters Options

    - by prp
    Sample Data : input : "abcdacdc" Output : "cadb" here we have to sort strings in order of count of characters. If the count is same for characters. maintain the original order of the characters from input string. my approach: i have used array of 26 for maintaining occurrence of all characters and sort it then print it.But while doing so i am not able to maintain order in case if two characters have same count. please suggest any improvement or any other algo.

    Read the article

  • Count the number of dates between two dates

    - by Matt Mitchell
    I'm looking to count the dates covered (inclusive) between two DateTimes (not .TotalDays) For example: 2012-2-1 14:00 to 2012-2-2 23:00 -> 2 2012-2-1 14:00 to 2012-2-2 10:00 -> 2 2012-2-1 14:00 to 2012-2-1 15:00 -> 1 2012-1-1 00:00 to 2012-12-31 23:59 -> 366 I can get this functionality with the code below: DateTime dt1 = new DateTime(2000,1,2,12,00,00); DateTime dt2 = new DateTime(2000,1,3,03,00,00); int count = 0; for (DateTime date = dt1; date.Date <= dt2.Date; date = date.AddDays(1)) count++; return count; Is there a better way?

    Read the article

  • Get category count for a category where only the child categories have products

    - by Matthew
    I'm having problems getting a count for a category collection that will include products in any of that categories children. However I don't want just a full count I want to filter that count by a product collection (so only include products in the count that appear in the product collection)... Any suggestions? Code to get a filtered product collection (filtered by a multiselect attribute) /** @var $attribute Mage_Eav_Model_Entity_Attribute */ $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection') ->setAttributeFilter($attribute->getId()) ->addFieldToFilter('value', array ('like' => $make)) ->addFieldToSelect('option_id') ->setStoreFilter(0, false); $set = array(); foreach($valuesCollection as $option){ $set[] = $option->getData('option_id'); } $_productCollection = Mage::getResourceModel('catalog/product_collection') ->addAttributeToFilter('sparex_makemodel', array('in' => $set ) ) ->addAttributeToSelect('*'); I'm getting the child categories for a given category like thus.. $childCats = Mage::getModel('catalog/category')->load(2)->getChildrenCategories(); Now none of these categories have products assigned to them, however their children (or children of children) do. I want to produce a count for these categories that includes the child categories but only where the products are in my filtered collection.

    Read the article

  • Select count() max() Date HELP!!! mysql oracle

    - by DAVID
    Hi guys i have a table with shifts history along with emp ids im using this code 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. NOW how do i choose the employee with the highest no of shifts under the specified range date, please this is really important

    Read the article

  • Count number of given object in a list with LINQ

    - by Aaginor
    I have a list which can contain multiple occurrences of the same object. Now I need to count, how often the given object is contained in this list. int count = 0; foreach (IMyObject item in myList) if (item == object2Count) count++; I am sure that this can be done nicer with LINQ, but LINQ is still a mystery to me. My first question is: How would I count the objects via LINQ and the second question: Will this LINQ version be slower or faster? I am using a ObservableCollection and the number of items in the list is usally rather small ... usally not more then 20. Thanks in advance, Frank

    Read the article

  • Can't return nil, but zero value of slice

    - by Sergi
    I am having the case in which a function with the following code: func halfMatch(text1, text2 string) []string { ... if (condition) { return nil // That's the final code path) } ... } is returning []string(nil) instead of nil. At first, I thought that perhaps returning nil in a function with a particular return type would just return an instance of a zero-value for that type. But then I tried a simple test and that is not the case. Does anybody know why would nil return an empty string slice?

    Read the article

  • mySQL: Can I make count() honor limit clause?

    - by Stomped
    I'm trying to get a count of records matching certain criteria within a subset of the total records. I tried (and assumed this would work) SELECT count(*) FROM records WHERE status = 'ADP' LIMIT 0,10 and I assumed this would tell me how many records of status ADP were in that set of 10 records. It doesn't - it returns, in this case 30, which is the total number of ADP records in the table. How do I just count up the records matching my criteria including the limit?

    Read the article

  • mysql - check if data exists across multiple tables

    - by Dd Daym
    I am currently running this query inside MySQL to check if the specified values exists within the table associated with them. SELECT COUNT(artist.artist_id), COUNT(album.album_id), COUNT(tracks.track_id) FROM artist, album, tracks WHERE artist.artist_id = 320295 OR album.album_id = 1234 OR tracks.track_id = 809 The result I get from running this query is all 1, meaning that all the statements after the WHERE clause is true. To further check the query's reliability, I changed the tracks.track_ = 809 to 802, which I know does not match. However the results displayed are still all 1, meaning that they were all successfully matched even when I purposefully inserted a value which would not have matched. How do I get it to show 1 for a match and 0 for no matches within the same query? EDIT: I have inserted an image of the query running

    Read the article

  • Does SELECT COUNT(*) work with MySQLi prepared statements?

    - by wordman
    I'm working on a test page and am using MySQLi prepared statements in my queries after reading they make my code safe from SQL injection. I have been successful with prepared statements so far with retrieving data from my DB, that all works great. What I want to do now is count the number of galleries within a project using SELECT COUNT(*). That's it. Without using a prepared statement, my old query looked like this: // count number of galleries per project $conn = dbConnect('query'); $galNumb = "SELECT COUNT(*) FROM pj_galleries WHERE project = {$pjInfo['pj_id']}"; $gNumb = $conn->query($galNumb); $row = $gNumb->fetch_row(); $galTotal = $row[0]; But for all my reading and searching the internet, I can not find out the proper way to write this as a prepared statement. I'm no PHP whiz here, and not coding daily isn't helping my skills. If I've missed anything please ask. Many thanks!

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >