LittleSmudge
Programmer
I'm struggling with this and I hope a fresh pair of eyes might help.
I have two tables
tblSite
SiteId
Addr1
Addr2
Prom
( and other fields )
tblJob
JobId
SiteRef This is FK to tblSite
DoneDate
JobType
( and other fields )
Relationship is classic One to Many
There may be NONE, one or many Jobs per site.
I need to create a query that outputs
SiteId, Addr1, Prom, CurrentJobs, ContExists
SiteId, addr1 and Prom are easy from tblSite
CurrentJobs is a Number
SELECT Count(JobId) As CurrentJobs
FROM tblSite LEFT JOIN tblJob
ON tblSite.SiteId = tblJob.SiteRef
WHERE IsNull([DoneDate])
ContExists is Boolean
SELECT (Not IsNull([DoneDate])) And ([JobType]=1 Or [JobType]=13) AS LeaseExists
FROM tblSite LEFT JOIN tblJob
ON tblSite.SiteId = tblJob.SiteRef
I can get these to work individually but I can't seem to find the way to combine them into a single SQL string.
What I'm after will look like
etc. ..
Any ideas ?
G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
I have two tables
tblSite
SiteId
Addr1
Addr2
Prom
( and other fields )
tblJob
JobId
SiteRef This is FK to tblSite
DoneDate
JobType
( and other fields )
Relationship is classic One to Many
There may be NONE, one or many Jobs per site.
I need to create a query that outputs
SiteId, Addr1, Prom, CurrentJobs, ContExists
SiteId, addr1 and Prom are easy from tblSite
CurrentJobs is a Number
SELECT Count(JobId) As CurrentJobs
FROM tblSite LEFT JOIN tblJob
ON tblSite.SiteId = tblJob.SiteRef
WHERE IsNull([DoneDate])
ContExists is Boolean
SELECT (Not IsNull([DoneDate])) And ([JobType]=1 Or [JobType]=13) AS LeaseExists
FROM tblSite LEFT JOIN tblJob
ON tblSite.SiteId = tblJob.SiteRef
I can get these to work individually but I can't seem to find the way to combine them into a single SQL string.
What I'm after will look like
Code:
SiteId, Addr1, Prom, CurrentJobs, ContExists
1 1 The Road -1 0 0
2 No 3 Hi St. -1 0 -1
3 The House -1 2 0
4 Ivy Cottage -1 1 0
5 Old Mill -1 0 -1
Any ideas ?
G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.