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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL group query : do not ignore Null

Status
Not open for further replies.

Extinct

Programmer
May 14, 2002
40
BE
Hi,

I have 2 linked tables tblProjects and tblActions. They are linked on ProjectId. The records in tblActions contain a date. I want to get a list of all Projects with the lowest date and highest date.

I have the following SQL but the problem with aggregate functions is that NULL values are ignored, so the projects where no actions are defined do not appear in the list.

Does anyone have a solution?

SELECT tblProjects.ProjectId AS ProjectId, Name, ProjectManager, Min(Date) AS MinOfDate, Max(Date) AS MaxOfDate FROM tblProjects LEFT JOIN tblActions ON tblProjects.ProjectId = tblActions.ProjectId GROUP BY tblProjects.ProjectId, Name, ProjectManager

 
u would be better of using two queries:
sql="select * from tblProjects"
rs.open sql,con
do until rs.eof
sql1="select * from tblActions"
rs.movenext
loop

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top