You may have to run two queries and combine the results
Query 1 :
Get all the active appointments with no activity party records linked at all.
FETCH :
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="appointment" >
<attribute name="subject" />
<attribute name="statecode" />
<attribute name="scheduledstart" />
<attribute name="scheduledend" />
<attribute name="createdby" />
<attribute name="regardingobjectid" />
<attribute name="activityid" />
<attribute name="instancetypecode" />
<order attribute="subject" descending="false" />
<filter type="and" >
<condition attribute="statecode" operator="in" >
<value>0</value>
<value>3</value>
</condition>
</filter>
<link-entity name="activityparty" from="activityid" to="activityid" link-type="outer" alias="ab" />
<filter type="and" >
<condition entityname="ab" attribute="activityid" operator="null" />
</filter>
</entity>
</fetch>
C# :
// Define Condition Values
var QEappointment_0_statecode_1 = 0;
var QEappointment_0_statecode_2 = 3;
// Instantiate QueryExpression QEappointment
var QEappointment = new QueryExpression("appointment");
QEappointment.Distinct = true;
// Add columns to QEappointment.ColumnSet
QEappointment.ColumnSet.AddColumns("subject", "statecode", "scheduledstart", "scheduledend", "createdby", "regardingobjectid", "activityid", "instancetypecode");
QEappointment.AddOrder("subject", OrderType.Ascending);
// Define filter QEappointment.Criteria
var QEappointment_Criteria_0 = new FilterExpression();
QEappointment.Criteria.AddFilter(QEappointment_Criteria_0);
// Define filter QEappointment_Criteria_0
QEappointment_Criteria_0.AddCondition("statecode", ConditionOperator.In, QEappointment_0_statecode_1, QEappointment_0_statecode_2);
var QEappointment_Criteria_1 = new FilterExpression();
QEappointment.Criteria.AddFilter(QEappointment_Criteria_1);
// Define filter QEappointment_Criteria_1
QEappointment_Criteria_1.AddCondition("ab", "activityid", ConditionOperator.Null);
// Add link-entity QEappointment_activityparty
var QEappointment_activityparty = QEappointment.AddLink("activityparty", "activityid", "activityid", JoinOperator.LeftOuter);
QEappointment_activityparty.EntityAlias = "ab";
//Perfrom retrieve multiple to get the number of records and keep this in a variable
Query 2: The following query should return all the appointment with no required attendees but because of the way the FETCH query works, will include some that does have required attendees. What you have to do is to filter the results to exclude those and then merge with the list from query 1.
FETCH
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="appointment" >
<attribute name="subject" />
<attribute name="statecode" />
<attribute name="scheduledstart" />
<attribute name="scheduledend" />
<attribute name="createdby" />
<attribute name="regardingobjectid" />
<attribute name="activityid" />
<attribute name="instancetypecode" />
<order attribute="subject" descending="false" />
<filter type="and" >
<condition attribute="statecode" operator="in" >
<value>0</value>
<value>3</value>
</condition>
</filter>
<link-entity name="activityparty" from="activityid" to="activityid" link-type="inner" alias="ag" >
<filter type="and" >
<condition attribute="participationtypemask" operator="ne" value="5" />
</filter>
</link-entity>
</entity>
</fetch>
C#
// Define Condition Values
var QEappointment_statecode_1 = 0;
var QEappointment_statecode_2 = 3;
var QEappointment_activityparty_participationtypemask = 5;
// Instantiate QueryExpression QEappointment
var QEappointment = new QueryExpression("appointment");
QEappointment.Distinct = true;
// Add columns to QEappointment.ColumnSet
QEappointment.ColumnSet.AddColumns("subject", "statecode", "scheduledstart", "scheduledend", "createdby", "regardingobjectid", "activityid", "instancetypecode");
QEappointment.AddOrder("subject", OrderType.Ascending);
// Define filter QEappointment.Criteria
QEappointment.Criteria.AddCondition("statecode", ConditionOperator.In, QEappointment_statecode_1, QEappointment_statecode_2);
// Add link-entity QEappointment_activityparty
var QEappointment_activityparty = QEappointment.AddLink("activityparty", "activityid", "activityid");
QEappointment_activityparty.EntityAlias = "ag";
// Define filter QEappointment_activityparty.LinkCriteria
QEappointment_activityparty.LinkCriteria.AddCondition("participationtypemask", ConditionOperator.NotEqual, QEappointment_activityparty_participationtypemask);
Let me know if you need further assistance on this.