I am using the ForcetK to query a group of records. The Response says that it has 3000 records but it is only returning 2000 in the Array. Any Ideas?
code:
var query = "Select Id, Name, (Select Id, Name FROm childObject) FROM object";
client.query(query, response);
function returnResponse(response) {}
Related
I run the below sql server script to retrieve some data , but I need to add column to tell me in each LEAGUE which user is first, second and so on
Select
(Select Name From League Where ID = League_Details.League_ID) As League
,Player
,(Select Total From AllUserPoints Where User_ID = Player) As Total
From
League_Details
Where
LeagueType = 'Private'
order by League
this is the result:
You have to use order by properly in this statement.
Try this one:
Select (Select Name From League Where ID = League_Details.League_ID) As League
,Player, (Select Total From AllUserPoints Where User_ID = Player) As Total
From
League_Details
Where
LeagueType = 'Private'
order by League, Total desc
Try this and Let me know whether it works on not.
I have 2 custom object.
1 - namespace__object1__c
2 - namespace__object2__c
I have lookup relationship in custom object namespace__object2__c.
Now i want to query id record from object2 where object1 id = (provided parameter)
String s = 'a6T3k0000LMJcEAO';
string query = 'select ID, (select ID from namespace__object1__c where ID = :s ) from namespace__object2__c';
SObject rObject = database.query(query);
system.debug(rObject);
object2 has lookup to object1, right? What's the field name?
SELECT Id, Name
FROM namespace__object2__c
WHERE namespace__object1__c = 'a6T3k0000LMJcEAO'
should work. Put the right field name in (lookup field typically is but doesn't have to be identical).
Some other things you can do with this (but let's use std. objects in example)
SELECT Id, Name
FROM Contact
WHERE AccountId = '001...'
SELECT Id, Name, Account.Name
FROM Contact
WHERE Account.Name LIKE 'Acme%'
And even
SELECT Id, Name
FROM Account
WHERE Id IN (SELECT AccountId FROM Contact WHERE LastName = 'Smith')
I want to do a nested aggregation, is this possible? SQL Server 2012 is returning an error when I try to do the following:
SELECT SUM(COUNT(memberID)) FROM table
The situation I have is the following:
I have members who have the same member ids as their dependents in the same table. I want to get the count of the the members and their dependents based on the memberID, however, I want the count in a column next to the main enrollee which is identified by another column as an e.
SELECT memberID, memberName, COUNT(memberID)
FROM table
WHERE memberRole = 'e'
The above would return 1 for all results, so I was thinking if I count the memberIds, then sum them would work but that returned an error, Am I doing something wrong? What is the best way to reach this porblem
Your original query was correct, with a slight change:
SELECT MemberID, MemberName, (SELECT COUNT(MemberID) FROM table WHERE MemberID = M.MemberID GROUP BY MemberID) AS MemberCount
FROM table M
WHERE M.MemberRole = 'E'
try this:
SELECT memberID, memberName, Sum(CNT) From
(
SELECT memberID, memberName, COUNT(memberID) CNt
FROM table
WHERE memberRole = 'e'
) t
group by memberID, memberName
I have a list, and I want to grab two sets of rows from that list based on myID value. However, I don't want to grab 2 items with the same value in "myOtherField". This is easy enough in SQL. Can I accomplish this in Linq?
select * from myTable where myID = 25
union
select * from myTable where myID = 35
and myOtherField not in (select myOtherField from myTable where myID = 25)
http://msdn.microsoft.com/en-us/library/bb386993.aspx
How would you do a "not in" query with LINQ?
var query =
(from obj in MyTable
select obj)
.Union
(from obj in Mytable
where obj.myid = 35 && !(from obj.myotherfield in mytable
select obj)
.Contains(obj => obj.myid=25)
select obj)
;
I am having two tables Room_master and Room_Item
Room_Master => roomid - pk, roomname
Room_Item => roomiteid - pk, roomid - fk, itemid, quantity
I want a list of rooms that do not have any items assigned.
I've written a SQL query as below to get the result
select * from room where roomid in
(select roomid from (select SUM(quantity) as qty, roomid from Room_Item group by roomid )
as newtab where qty=0) order by roomid
My respective Linq query is as following
var roomitem1 = from ri in objEntities.Room_Item
group ri by ri.roomid into p
select new { roomid = p.Key, totalitem = p.Sum(row => row.quantity) };
var roomid = roomitem1.Where(x => x.totalitem > 0).Select(x => x.roomid);
The Linq query is working very fine but problem is that it takes too long time to
return the data. I have 6000 records in Room_master table and about 70000 records in Room_item table and it takes about 2 minutes to return data back to my view...
How can I optimize my Linq query so that it runs faster?
Totally untested:
objEntities.Room_Item
.GroupBy(ri => ri.RoomId) // group all items by room id
.Where(g => g.Sum(r => r.quantity) == 0) // where the total quantity of all items for that room id is 0
.Select(g => g.Key)
Should give you a list of room ids having no items assigned