w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
What is the reference count for the object returned by [NSMutableDictionary dictionary]
temporaryDictionary is in auotorelese pool, so the retain count can be 1 at some time and 0 at some another point of time.. And yes, its never recommended to rely on retainCount property.

Categories : Objective C

fetching salesforce object's record count using java
The following may work for you. In my system I have an object Device that is a child of Account. There is also an object Alert that is a child of Device. I used an aggregate query to get the account ids for Alert records that meet a certain condtion. StringBuilder openAlertQuery = new StringBuilder(); openAlertQuery.append("SELECT Device__r.Account__c"); openAlertQuery.append(" FROM Alert__c WHERE Cleared__c = FALSE GROUP BY Device__r.Account__c"); List<SObject> alertRecords = sfdcServer.doQuery(openAlertQuery.toString()); List<String> accountIds = new ArrayList<String>(); for (SObject alert : alertRecords) { String accountId = (String) alert.getChild("Account__c").getValue(); accountIds.add(accountId); } Notice the SObject method is getChild(name) rather th

Categories : Java

Proper Use of COUNT to count number of rows returned in a SELECT statement
SELECT FirstName, MiddleName, LastName, [count] = COUNT(*) OVER() FROM Person.Person TABLESAMPLE (10 PERCENT); Though you may prefer the following, since TABLESAMPLE has some issues IIRC (for me, TABLESAMPLE returns an unpredictable number of rows every time, and it also prevents you from counting rows from the entire table): SELECT TOP 10 PERCENT FirstName, MiddleName, LastName, [count] = COUNT(*) OVER() FROM Person.Person ORDER BY [something]; If you really want a random set of rows, you can use ORDER BY NEWID();. And if you want the actual count returned by the query, not the count of rows in the actual table, just follow your query (without the COUNT aggregate) with: SELECT @@ROWCOUNT; Also please don't use 'single quotes' for column aliases - this syntax is deprecat

Categories : Sql Server

sqlite3 - efficient way to count rows returned from SELECT statement in PHP without using COUNT()
Normally, you can use PDOStatement::rowCount(), however, SQLite v3 does not appear to provide rowcounts for queries. You would need to seperately query the count(*), or create your own counting-query-function. The documentation comments have an example of this

Categories : PHP

SQL query: How to select record from other table where no record exist or count = 0 (conditional)
Use a LEFT JOIN and check for a NULL primary key on the joined table: SELECT StaffDB.* FROM StaffDB LEFT JOIN EmploymentHistory ON StaffDB.SID = EmploymentHistory.SID AND EmploymentHistory.isCurrent = 1 WHERE EmploymentHistory.HistID IS NULL Or use EXISTS - this will possibly be more performant, although not as easily readable (subjective): SELECT * FROM StaffDB WHERE NOT EXISTS (SELECT 1 FROM EmploymentHistory WHERE EmploymentHistory.SID = StaffDB.SID AND EmploymentHistory.isCurrent = 1)

Categories : SQL

Active Record, count of grandchild association record
In your models you can define a through association. class Town < ActiveRecord::Base has_many :citizens has_many :cars , :through => :citizens end And query like this. @town.cars.count or Town.find("town id").cars.count

Categories : Ruby On Rails

Run SQL function for each returned record
You just use the function in your select: For example if you have a scalar function. select ClientId, dbo.YourFunction(ClientId) as FunctionReturnValue from YourTable If you have a Table Value Function try this: select ClientId, FunctionReturnValue from YourTable cross apply dbo.YourFunction(YourTable.ClientId)

Categories : SQL

Angular since 1.1.1 returned resource hash as separate symbols
So, problem is done, according this question: since 1.1.1 version, angular need ".json" affix in each resource url: app.factory "Post", ($resource, apiPrefix) -> $resource( apiPrefix + "/posts/:id.json", id: "@id" , update: method: "PUT" )

Categories : Ruby On Rails

Value Returned from Angular JS $resource POST Not Matching Server Output
Your var updated = Feed.update(post); makes an async call to the server and returns immedaitly and the updated object gets updated as soon as the server returns the data. So I guess you try to access the updated.StarId too early. From the angular doc: It is important to realize that invoking a $resource object method immediately returns an empty reference (object or array depending on isArray). Once the data is returned from the server the existing reference is populated with the actual data. This is a useful trick since usually the resource is assigned to a model which is then rendered by the view. Having an empty object results in no rendering, once the data arrives from the server then the object is populated with the data and the view automatically re-renders itself showing the new

Categories : Angularjs

SQL Query: Comparing two dates in returned record
Just add a WHERE clause to get started: SELECT tblOne.ServiceID, tblTwo.AccountNbr, tblTwo.AcctName, tblFour.ServiceName, tblOne.Status, tblThree.BeginDate, tblThree.EndDate, tblOne.ServiceYear, tblFive.ServiceBegin, tblFive.ServiceEnd FROM ((tblTwo INNER JOIN tblFour ON tblTwo.AccountNbr=tblFour.AccountNbr) INNER JOIN (tblThree INNER JOIN tblOne ON tblThree.ServiceID=tblOne.ServiceID) ON tblFour.ClientID=tblOne.ClientID) INNER JOIN tblFive ON tblOne.ContractID=tblFive.ContractID WHERE tblThree.EndDate > tblFive.ServiceEnd;

Categories : SQL

Creating new Object from resource and modifing it changes resource
Marek read this article, it explains your doubts http://android-developers.blogspot.com/2009/05/drawable-mutations.html

Categories : Android

How to format node.js sqlite3 record set as a JSON object of record arrays
Based on what I know of JSON I was expecting the whole recordset to be enclosed with curly brackets, and each record to be enclosed with a square bracket. However I'm seeing the opposite. Nope, you have it backward. Database results will be modeled as an array of objects - 1 array represents the results of the entire query, and each object in that array represents a single result record. In JSON, Arrays use square brackets, objects use curly braces (Same as actual JavaScript code).

Categories : Json

Call Access query and add column for each record returned
Similar to my answer here, you can create a VBA function to include the number of weekdays using SELECT ... , CountWeekdays(tbl1.EntryDate, tbl2.EntryDate) AS TotalWeekdays FROM ... Just create a new Module in Access and paste the following code into it: Public Function CountWeekdays(Date1 As Date, Date2 As Date) As Long Dim StartDate As Date, EndDate As Date, _ Weekdays As Long, i As Long If Date1 > Date2 Then StartDate = Date2 EndDate = Date1 Else StartDate = Date1 EndDate = Date2 End If Weekdays = 0 For i = 0 To DateDiff("d", StartDate, EndDate) Select Case Weekday(DateAdd("d", i, StartDate)) Case 1, 7 ' weekend - do nothing Case Else Weekdays = Weekdays + 1 End Select Next CountWeekdays = Weekdays

Categories : SQL

Codeigniter Active Record / MySQL Query - group_by causes only one row to be returned
UPDATE: based on your comments and updated question your base SQL query might look like SELECT s.*, q.categories, t4.* FROM services s LEFT JOIN ( SELECT sc.service_id, GROUP_CONCAT(c.cat_name) categories FROM service_categories sc JOIN categories c ON sc.cat_id= c.cat_id GROUP BY sc.service_id ) q ON s.service_id = q.service_id LEFT JOIN table4 t4 ON s.service_id = t4.service_id WHERE s.user_id = ? Sample output: | SERVICE_ID | OTHER_SERVICE_COLUMNS | USER_ID | CATEGORIES | ------------------------------------------------------------------- | 23 | other data | 14 | cleaning,washing | | 24 | other data | 14 | drying,scrubbing | Here is SQLFiddle demo Now a possible version of CI code $sql = "SELECT s.*, q

Categories : Mysql

SQL Count the numbers in a returned query?
You could use that same query as a derived table for another one. Like this: select num_contact_names, count(*) from (SELECT sbg.contact_email, COUNT(DISTINCT sbg.contact_name) Num_Contact_Names FROM SummaryBillGroup sbg INNER JOIN Account a ON sbg.Customer_number = a.Customer_number WHERE a.account_status_code 'c' GROUP BY sbg.contact_email) as t group by t.num_contact_names order by 2 First row would give you 1's, second row the 2's and so on. Cheers.

Categories : SQL

Count rows returned from a GROUP BY
If you want the total count of rows, remove the "group by" and "order" (the first one is the problem, the second one simply un-necessary since there's no ordering a single row). SELECT COUNT(*) FROM `applications` WHERE approved =0 If you want the total count of user_ids, switch "count(*)" to "count(distinct user_id)" The reason you get 2 rows now is because GROUP BY clause print counts per-group. You can see that if you add "user_id" to your select: SELECT COUNT(*) , user_id FROM `applications` WHERE approved =0 GROUP BY user_id ORDER BY `applications`.`user_id` ASC Which will returns two rows like this COUNT(*) , user_id 1 , user1 1 , user2

Categories : Mysql

how to select a record from one table and count the number of which appears another table and count it
Please try: SELECT *, (SELECT COUNT(*) FROM Student t2 WHERE t1.teacher_id=t2.tearcher1_id OR t1.teacher_id=t2.teacher2_id OR t1.teacher_id=t2.tearcher3_id) num_selected_by_stu FROM Teacher t1

Categories : SQL

Get count of each element returned by mysql query
I think ideal result should look like this: $data = array( "Brand" => array(brand1 => 1, brand2 => 2), "Colour" => array(colour1 => 1, colour2 => 2), "Occassion" => array(Occassion1 => 1, Occassion2 => 2), ); For each subarray we can draw a histogram. The code will look like this: $query = " SELECT `Brand`,`Colour`,`Occassion`,`Fabric`,`Type` FROM `deals` WHERE `Size` LIKE '%XS%'"; $data = array( "Brand" => array(), "Colour" => array(), "Occassion" => array(), "Fabric" => array(), "Type" => array(), ); if ($result = $mysqli->query($query)) { /* fetch associative array */ while ($row = $result->fetch_assoc()) { foreach($row as $key => $value) { $da

Categories : PHP

Count number of records returned by each group by
You can use the OVER clause (SQL Server 2008+): SELECT col1, col2, col3, col4, COUNT(*) OVER(PARTITION BY col1) [Count] FROM Table1 AS t1 The results are: ╔════════╦════════╦════════╦════════╦═══════╗ ║ COL1 ║ COL2 ║ COL3 ║ COL4 ║ COUNT ║ ╠════════╬════════╬════════╬════════╬═══════╣ ║ data1 ║ data2 ║ data3 ║ data4 ║ 2 ║ ║ data1 ║ data2 ║ data3 ║ data5 ║ 2 ║ ║ data10 ║ data11 ║ data12 ║ data13 ║ 3 ║ ║ data10 ║ data11 ║ data12 ║ data14 ║ 3 ║ ║ data10 ║ data11 ║ data12 ║ data15 ║ 3 ║ ╚══════

Categories : Sql Server

How can I count number of rows returned by a join in Slick?
That's an interesting issue. Usually with SQL, you alias the other column which would cause a name collision but I'm not sure how that works with Slick (or if even possible). But you can work around this I believe by only selecting a single column if you just want to count: val query = for { h <- Houses r <- Rooms if h.id === r.houseId } yield h.id.count Now the count call on id is deprecated, but this one produced a clean sql statement which looks like this: select count(x2.`id`) from `Houses` x2, `Rooms` x3 where x2.`id` = x3.`houseId` Anything that I tried using .length produced a bunch of sql that was not correct. EDIT In response to your comment, it you wanted to leave the query the way it was (and let's forget that the query itself is broken due to field collisi

Categories : Scala

SSRS 2008 - Count instances of a returned result
You can use two different queries, just using grouping and a sub-query: DECLARE @driverInfo TABLE ( Name varchar(50), TimeOn datetime, TimeOff datetime ) INSERT INTO @driverInfo SELECT 'David Niven', '2013-07-23 09:00', '2013-07-23 12:00' UNION ALL SELECT 'John Jones', '2013-07-23 09:00', '2013-07-23 16:00' UNION ALL SELECT 'David Niven', '2013-07-23 13:00', '2013-07-23 18:00' UNION ALL SELECT 'David Niven', '2013-07-24 09:00', '2013-07-24 11:00' UNION ALL SELECT 'Paul Newman', '2013-07-23 09:00', '2013-07-23 12:00' -- used for first data set SELECT *, DATEDIFF(hour, TimeOn, TimeOff) AS [TotalHours] FROM @driverInfo -- used for second data set SELECT Name, COUNT(*), SUM(TotalHours) FROM ( SELECT Name, DATEDIFF(hour, TimeOn, TimeOff) AS [TotalHours] FROM @driverInfo

Categories : Reporting Services

Unable to insert any record and returns error:MySQL returned an empty result set (i.e. zero rows)
$query="INSERT INTO uploads(file_name,file_size,file_type,description)VALUES('{$_FILES['image']['name']}',{$_FILES['image']['size']},'{$_FILES['image']['type']}','$d')"; mysql_query($query) or die(mysql_error()); I'm assuming your description field doesn't just take integers. Put single quotes around strings being inserted into the database. mysql_query is also deprecated. Use mysqli or pdo to perform queries.

Categories : PHP

Trying to count number of rows returned from MySQL joined table
The problem is that you are using an aggregate function with no GROUP BY so the results are being reduced into a single row. MySQL uses an extension to GROUP BY which allows columns in the select list to appear outside of an aggregate function or GROUP BY clause, this however can lead to unexpected results. (see MySQL Extensions to GROUP BY) From the MySQL Docs: MySQL extends the use of GROUP BY so that the select list can refer to nonaggregated columns not named in the GROUP BY clause. ... You can use this feature to get better performance by avoiding unnecessary column sorting and grouping. However, this is useful primarily when all values in each nonaggregated column not named in the GROUP BY are the same for each group. The server is free to choose any value from each group, so u

Categories : Mysql

How to count documents returned by Node-MongoDB-native stream()?
You can try calling collection.count first. collection.count(function(err, total) { var count = 0; var progress = 0; function onData() { progress = (++count / total) * 100; } var stream = collection.find(query, fields, options).stream() .on("data", onData) .on("end", onEnd) .on("error", onError); });

Categories : Node Js

PHP COUNT and skip every other record
You could add a row-number, then use MOD (=> pos % 2) to take the odd or even rows. Something like this: SELECT a.* FROM ( SELECT @row := @row + 1 AS pos, t.* FROM your-TABLE t, (SELECT @row := 0) b ) a WHERE pos % 2 = 0

Categories : PHP

mysql How to get count of a query's resultant rows with conditions on column returned by datediff
Something like this should work: SELECT SUM(days_taken <= 5) AS within_5_days, SUM(days_taken > 5) AS more_than_5, SUM(days_taken IS NULL) as not_yet_referred FROM (...) AS subquery Obviously, the subquery should produce NULL for non-referred clients, not N/A as in your original subquery.

Categories : Mysql

Combine SELECTing a record with COUNT
One more try ... SELECT *, COALESCE((a.magnitude / g.generated), 0) AS result FROM ( SELECT COUNT(*) AS generated FROM logs INNER JOIN generated_logs ON generated_logs.log_fk = logs.log_pk WHERE logs.department_fk = ? AND DATE(generated_logs.generated_time) = ? ) AS g, ( SELECT COUNT(generated_logs.log_fk) AS magnitude, logs.name FROM logs INNER JOIN generated_logs ON generated_logs.log_fk = logs.log_pk WHERE logs.department_fk = ? AND generated_logs.acknowledged = 1 AND DATE(generated_logs.generated_time) = ? GROUP BY generate

Categories : PHP

MySQL - count how many rows in next 5 seconds for each record
Sometimes a join outperforms a subquery. You could try: select p1.ApplyID , p1.ApplyDate, , count(*) from tb p1 join tb p2 on p2.ApplyDate between p1.ApplyDate and p1.ApplyDate + interval 5 second group by p1.ApplyID , p1.ApplyDate order by p1.ApplyDate Creating an index on ApplyDate might help: create index IX_TB_ApplyDate on tb (ApplyDate, ApplyID) Two notes. Because you only select ApplyID and ApplyDate, this index is even covering for your query. And make sure your query doesn't use UNIX_TIMESTAMP, which may prevent MySQL from using the index.

Categories : Mysql

Dynamic array reference count in record
Let's take a look at this function: procedure TestConcatenation; var r1 : TRec; begin r1 := r1 + 65; end; The compiler actually implements it like this: procedure TestConcatenation; var r1 : TRec; tmp : TRec; begin tmp := r1 + 65; r1 := tmp; end; The compiler introduces a temporary local to store the result of r1 + 65. There's a very good reason for that. If it did not, where would it write the result of your addition operator? Since the ultimate destination is r1, if your addition operator writes directly to r1 it is modifying its input variable. There is no way to stop the compiler generating this temporary local.

Categories : Delphi

Replacing Model object by ViewModel object will raise an exception when trying to save a new record
First of all, change your ViewModel to this: public class ServerToEdit { public Server Server { get; set; } public TechnologyIP TechnologyIP { get; set; } } And, change your Action to this: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(ServerToEdit serverToEdit) { if (ModelState.IsValid) { try { repository.InsertOrUpdateServer(serverToEdit.Server, serverToEdit.TechnologyIP); repository.Save(); return RedirectToAction("Index"); } catch { // Some code... } } } Then, in your View, you'll have: @model TMS.ViewModels.ServerToEdit @* This partial view defines form fields that will appear when creating and editing entities *@ @Html.AntiForgeryToken() <div class=

Categories : Asp Net

Get record count in Kendo Grid after dataSource.read
According to the API Reference here the dataSource has a total() function. So you should be able to do the following, in theory: function refreshData(){ var grid = $("#SearchWindowGrid").data("kendoGrid"); grid.dataSource.read(); var count = grid.dataSource.total(); $("#countElement").val(count); }

Categories : Jquery

query that would count and increment the number of duplicate instances of that record
Add a field to your table. Choose AutoNumber as its data type and make it the table's primary key. I named the field ID, so my version of your sample data looks like this ... ID COL1 1 A 2 B 3 A 4 C 5 A The SELECT statement below returns this result set ... ID COL1 COL2a COL2b 1 A 1 1 2 B 1 1 3 A 2 2 4 C 1 1 5 A 3 3 COL2a and COL2b show 2 methods to achieve the same result. DCount is Access-specific, and required quotes around the m.COL1 text values. The second approach, COL2b, uses a correlated subquery so could work in a different database if you choose. And with that approach, you wouldn't need to bother about quoting text values. Either approach basically requires the db engine run an additional query for each

Categories : SQL

Multiple Select Count SQL queries in Codeigniter Active Record
here is the query in active records $rows = $this->db->select('b.brand_id,b.name') ->select('(select count(*) from items where brand_id = b.brand_id) as itemc',FALSE) ->select('(select count(*) from models where brand_id = b.brand_id) as modelc',FALSE) ->from('brands as b') ->limit($perpage,$page)->get()->result();

Categories : PHP

c++ using returned object to initialize an object
This is return value optimization. Your compiler is optimizing the unnecessary copies (as best as it can). EDIT: Check this question for further explanation.

Categories : C++

.Count() on the view is actually retrieving all the record from the database, and unnecessary SQL batch is generated
Try to pass your model to view as List instead of IQueryable: return View(groupRepository.AllIncluding(group => group.SecurityRoles).ToList());

Categories : Asp Net

MS Access - How to split one large table into smaller tables by record count
Bottom line, on the initial query, don't select the ID (Autonumber) column. Select the columns you want into the initial temp table, then alter the table to add a new counter column. I used COUNTER(1,1) so that each time the temp table is created, the first record is 1. I added a little nugget that saves the broken files to a folder. I commented out the error handling, but uncomment it to make sure your save directory is working correctly. Function SplitTables_RTPA_Actual() Dim rs As New ADODB.Recordset Dim cn As New ADODB.Connection Set cn = CurrentProject.Connection Dim rowcount As Long Dim tblcount As Integer Dim i As Integer 'Just don't select the ID column SQL = "SELECT Company, Incurred_By, Transaction_Type, Format(Transaction_Date, 'm

Categories : Ms Access

Entity Framework Count Parent rows that have a child record with a constraint
(from p in context.Parents where p.CreatedOn.Date == DateTime.Now.Date && p.Children.Any(c=>c.Address != null) // or p.Children.Any(c=>c.Address == true) select p).Count() May be something like this? You can also go from the children, for example: (from c in context.Child where c.Address == true && c.Parent.CreatedOn.Date == DateTime.Now.Date select c.Parent).Distinct().Count() In lambda expression, please note that I just used childObj.Address == true (most likely that condition is a bit different, but you should see the idea. context.ARC_Records .Where(d => (d.Signed == false || d.Signed == null) && d.ChildObject.Any(c=>c.Address == true)) .Count();

Categories : Entity Framework

Get record count between startdate and endate (VBA) based on user input Access
You are declaring LTotal as an integer, then you are initialising it with a string, that's why you are getting a type 13 error. To solve your issue, you have to understand what you are doing: you need to execute a query against the database engine to be able to get a result, then you need to read the returned resultset. A string itself will just contain a series of characters, it will not do anything for you. The simplest way for you to achieve what you want is to use the internal DCount() function: Dim LTotal as Integer LTotal = Dcount("*", "tblMatchBook", "(DateFinished >= [Forms]![frmRptDates]![txtSDate]) AND ([DateReceived] <= [Forms]![frmRptDates]![txtEDate])") MsgBox LTotal You actually do not need VBA to use this. You can simply paste the following in the ControlSource

Categories : Ms Access

Is there a way to know what the returned object is?
As far as I'm aware, you are not able to do it in a simple way. what I can think of to achieve a similar behavior is to use type constraint at your helper class. Create a base Helper class (let's say MyHelper) which has a virtual GetAttachedDataObject returning object type, while deriving another class - MyHelper<T>, which has a method GetAttachedData<T> returning value of type T. When you initialize/instantiate the helper, instantiate a strong typed MyHelper<T>. At the caller, you can cast your MyHelper to your desired MyHelper<T> upfront and call GetAttachedData instead of GetAttachedDataObject. of course, you could further tweak this to meet your needs. but this is not ideal either - it still requires you to do casting at some point, though I believe it could

Categories : C#

The object is destroyed before being returned
The tmp Var exist in its scope... so it exists only inside operator += and _operation. When tmp is out of scope the destructor is called. The right way to do that is: Var& Var::operator += (const Var& var) { _operation(*this, &var, *this, VAR_ADD); return *this; } void Var::_operation(const Var& lhs, const Var& rhs, Var& res, VAR_OPERATOR op) { res == ... // operations // here the tmp variable has value } With the += operator we mean that internal data will changed (in this case that *this += val), so ther's no return type, or we can return *this, to have situation like: ( v += val ) - val2; in v += val will be called operator += and thre return is the changed v, now if we define - operator like friend Val operator - ( const Val& lhs,

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.