You need to sign in to do that
Don't have an account?
Plz Check the code
Hii All,
I have Scenario
that i made custom fireld
DATA Type:picklist
Field:Days__c
values{MOn,Tue,Wed,Thu,Fri,Sat,Sun]
and i have to get the o/p as Name :Mike NUmber of working daysDays :4
public with sharing class Workdays
{
public Workdays() { }
Account a = new Account();
List<Account> a1;
public list<Account> getAcclist()
{ return a1; }
public PageReference Attendance()
{
a1=[select count(id),name,Days__c from Account where name=:a.name Group by Days__c];
public Account getAccount() { return a; }
}
and i'm getting ERror:Error: Compile Error: Field must be grouped or aggregated: Name at line 14 column 6
can u plz guide how to apply group by function for this code
Thanks in Advance
public PageReference Attendance()
when you write PageReference you need to return a PageReference...
Hi,
As specified in the error if it an aggregate query that you are using then all the fields that you specified in select statement should be either used in group statement or it should be aggregated. Here name is not included in any of this. May be you can use
a1=[select count(id),name,Days__c from Account where name=:a.name Group by Days__c,name];
Hii meera
Yeah i'll look on that way
and tried to write the code in another way
can u have a look at this code
public class GroupedQuery{
public string GroupBy1 {get;set;}
public integer Count {get;set;}
public List<GroupedQuery> queryResults {get;set;}
public GroupedQuery()
{
List<Account> queries = [select id, Name,Count(Days__c) CountResult from Account group by Name]; }
queryResults = new List<GroupedQuery>();
for(Account query: queries)
{ GroupedQuery myObject = new GroupedQuery();
myObject.Count = Integer.valueOf(query.get(CountResult));
myObject.GroupBy1 = String.valueOf(query.get('Name'));
queryResults.Add(myObject);
}
}
and i'm getting the error
Compile Error: unexpected token: '=' at line 11 column 13
Canu u guys plz get me the error free code.. i tried with my little knwoledge in salesforce.. hope this code may extend my capabilities to learn on salesforce
Thanks in Advance
this will solve that specific error
Thanks for ur help Starz26.
But it's giving a Compile Error: Variable does not exist: CountResult at line 23 column 46
CountResult is the "count(Days__c)" value. It is not a variable. It should be given in quotes.
Well, I said it would only solve that ONE specific error :)
As the above poster stated, change
to