Hi,
I have a table called opportunity, included within this table are a opclosed
(date) , a companyid (integer) and some other columns.
There are many opportunity records per companyid . I am only interested in
closed opportunities i.e select * from opportunity where opclosed is not
null
The problem for me is I only need the latest opportunity for each company. -
returning back only the opportunityid. I am pulling my hair out trying to
figure out how to do it without going down the route of a cursor etc...
some Data:
ID Closed Data, CompanyID
61 2005-11-14 36
57 2005-11-14 37
59 2005-11-12 37
60 2005-11-13 37
63 2005-11-13 41
In the above example I would like to display a resultset of IDs= 61,57 and
63
Any pointers or help would be most appreciated.
kind regards
Mike
I have a table called opportunity, included within this table are a opclosed
(date) , a companyid (integer) and some other columns.
There are many opportunity records per companyid . I am only interested in
closed opportunities i.e select * from opportunity where opclosed is not
null
The problem for me is I only need the latest opportunity for each company. -
returning back only the opportunityid. I am pulling my hair out trying to
figure out how to do it without going down the route of a cursor etc...
some Data:
ID Closed Data, CompanyID
61 2005-11-14 36
57 2005-11-14 37
59 2005-11-12 37
60 2005-11-13 37
63 2005-11-13 41
In the above example I would like to display a resultset of IDs= 61,57 and
63
Any pointers or help would be most appreciated.
kind regards
Mike
Comment