"SELECT ep.EventPartID,e.StartDate, e.EventID,r.RelationshipID
FROM GhEvents e
inner join GhEventParts ep on e.EventID = ep.EventID
inner join GhRcEventParts rcep on ep.EventPartID = rcep.EventPartID
inner join GhRelationships r on rcep.RelationshipID = r.RelationshipID
inner join GhContacts c on r.ContactID = c.ContactID
inner join GhUsers u on u.UserID = r.UserID
left join GhGroupsContacts gc on gc.ContactID=c.ContactID
WHERE e.UserID = 235
and u.UserID = 235
and e.EventTypeID=5
and e.StatusCodeID=1
and r.StatusCodeID=1
and r.ContactID <> u.ContactID
and e.StartDate >= now()
ORDER BY e.StartDate DESC"
Here i need to change query to get the below results, i mean here group by last column, but i need to get the records that closed to current date. I used group by last column.
SELECT ep.EventPartID,e.StartDate, e.EventID,r.RelationshipID
FROM GhEvents e
inner join GhEventParts ep on e.EventID = ep.EventID
inner join GhRcEventParts rcep on ep.EventPartID = rcep.EventPartID
inner join GhRelationships r on rcep.RelationshipID = r.RelationshipID
inner join GhContacts c on r.ContactID = c.ContactID
inner join GhUsers u on u.UserID = r.UserID
left join GhGroupsContacts gc on gc.ContactID=c.ContactID
WHERE e.UserID = 235
and u.UserID = 235
and e.EventTypeID=5
and e.StatusCodeID=1
and r.StatusCodeID=1
and r.ContactID <> u.ContactID
and e.StartDate >= now()
GROUP BY r.RelationshipID
ORDER BY e.StartDate DESC
please help me out, i need the results should show startdate descending wise & events that are closer to current date.
Bookmarks