Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread bartsmissaert
Yes, you are right. Good thing the OP found it himself. RBS > actually > > SELECT COUNT(DISTINCT ... > > On 5/1/07, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: >> It will be as the below query, but replace: >> distinct p.* >> with: >> count(p.ID) >> >> RBS >> >> >> Allan, Mark wrote: >> >> > W

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Rich Shepard
On Tue, 1 May 2007, Allan, Mark wrote: Ok, so here's another question, how would I get the count of patients where the EVC and FVC > 2.0? COUNT * from SELECT ... There are several aggregate functions available in SQLite. Rich -- Richard B. Shepard, Ph.D. |The Environm

Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread P Kishor
actually SELECT COUNT(DISTINCT ... On 5/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: It will be as the below query, but replace: distinct p.* with: count(p.ID) RBS >> Allan, Mark wrote: >> > What I want is Joe Blogs just the once. >> > >> > >> Mark, >> >> Then try adding distinct like t

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Allan, Mark
> > Ok, so here's another question, how would I get the count of > patients where the EVC and FVC > 2.0? > Dont worry I have figured this out. I am doing:- select count (distinct p.PatientID) p.* from PatientsTable as p join ExaminationsTable as e on e.PatientID=p.ID join TestTable as t on t.E

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread bartsmissaert
It will be as the below query, but replace: distinct p.* with: count(p.ID) RBS >> Allan, Mark wrote: >> > What I want is Joe Blogs just the once. >> > >> > >> Mark, >> >> Then try adding distinct like this: >> >> select distinct p.* >> from PatientsTable as p >> join ExaminationsTable as e on e.P

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Allan, Mark
> Allan, Mark wrote: > > What I want is Joe Blogs just the once. > > > > > Mark, > > Then try adding distinct like this: > > select distinct p.* > from PatientsTable as p > join ExaminationsTable as e on e.PatientID=p.ID > join TestTable as t on t.ExamID=e.ID > join ForcedSpiroTable as f on f

Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Dennis Cote
Allan, Mark wrote: Excellent, thanks for your help. Mark, For future reference, your posts could use a little more trimming. There is no need to quote the entire string of messages from your original post on each reply. :-) Dennis Cote --

Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Dennis Cote
Allan, Mark wrote: What I want is Joe Blogs just the once. Mark, Then try adding distinct like this: select distinct p.* from PatientsTable as p join ExaminationsTable as e on e.PatientID=p.ID join TestTable as t on t.ExamID=e.ID join ForcedSpiroTable as f on f.TestID=t.ID join RelaxedSpir

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Allan, Mark
nd reformat it using > your favorite programming language. > > See, there is a difference between SQL's result and your expectation. > A SQL always returns a "table" -- a rectangular, rows x cols selection > where every cell is filled with something even if that "so

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread bartsmissaert
oes this make sense? What I need to do is find all patients that have an > EVC and FVC greater than 2.0. > > Is there a way to do this? Am I missing something? > > Thanks again > > Mark > > >> -Original Message- >> From: Dennis Cote [mailto:[EMAIL PROTE

Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread P Kishor
-- > From: Dennis Cote [mailto:[EMAIL PROTECTED] > Sent: 01 May 2007 15:31 > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] SQL query help (mutiple joins) > > > Allan, Mark wrote: > > I have a database that looks something like the following:- > > > > Pa

RE: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Allan, Mark
-Original Message- > From: Dennis Cote [mailto:[EMAIL PROTECTED] > Sent: 01 May 2007 15:31 > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] SQL query help (mutiple joins) > > > Allan, Mark wrote: > > I have a database that looks something like the following

Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread Dennis Cote
Allan, Mark wrote: I have a database that looks something like the following:- PatientsTable { ID, Name, Sex, } ExaminationsTable { ID, PatientID, } TestTable { ID, ExamID, .} ForcedSpiroTable { ID, TestID, EVC, IVC, IC ... } RelaxedSpiroTable { ID, TestID, FVC, FEV1, PEF, ...} Can

Re: [sqlite] SQL query help (mutiple joins)

2007-05-01 Thread bartsmissaert
select * from PatientsTable P inner join ForcedSpiroTable F on (P.ID = F.ID) inner join RelaxedSpiroTable R on (P.ID = R.ID) where F.EVC > 2.0 and R.FVC > 2.0 RBS > Hi, > > Can anyone offer any help with the following SQL query? > > I have a database that looks something like the following:- > >