Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping question

Status
Not open for further replies.

rjm13

Programmer
Feb 1, 2002
60
US
Hi All,

I am trying to construct a query that gives a clients first enrollment into a program, And what I need for results are the clients ID , date of first enrollment, Program, and the unique program enrollment identifier.

The query I have constructed is as follows:

SELECT dbo_ai_prog.tc_id, dbo_program.descript, Min(dbo_ai_prog.start_dt) AS MinOfstart_dt
FROM dbo_program INNER JOIN dbo_ai_prog ON dbo_program.prog_id = dbo_ai_prog.program
GROUP BY dbo_ai_prog.tc_id, dbo_program.descript
HAVING (((dbo_program.descript) Like "HR (RW)*"));

The problem is that if I try to add in the program enrollment unique identifier, it is making me group on it, the message says it has to be an aggregate function. I need to be able to just add in the program enrollment unique identifier and have it be part of the row but not group on it because then the query rturns all rows, because the field is a unique identifier.

Can anyone help me on this?

Thanks,

RJ

 
try using a subquery to select the id...

select blah, (select descript from dboProg WHERE id=id), blah...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top