Re: [sqlite] SQL query help

2011-08-20 Thread Paul Sanderson
Hmm thanks Roger Table could have a few million rows, i'll have a play and see what the run time is. The relevant column is indexed On 20 August 2011 17:14, Roger Andersson wrote: >  On 08/20/11 05:42 PM, Paul Sanderson wrote: >> Hi all >> >> I am trying to create a query that works to craete a

Re: [sqlite] SQL query help

2011-08-20 Thread Roger Andersson
On 08/20/11 05:42 PM, Paul Sanderson wrote: > Hi all > > I am trying to create a query that works to craete a subset of a table > based on duplicate items > > Examples work best so consider the contrived table with the following rows > 10 socata > 7 socata > 13 cessna > 2 piper > 7 piper > 55 pip

Re: [sqlite] SQL query help

2007-06-18 Thread Jeff Godfrey
- Original Message - From: "P Kishor" <[EMAIL PROTECTED]> To: Sent: Monday, June 18, 2007 2:55 PM Subject: Re: [sqlite] SQL query help On 6/18/07, Jeff Godfrey <[EMAIL PROTECTED]> wrote: I have a table which contains (among other things), a "name&quo

Re: [sqlite] SQL query help

2007-06-18 Thread P Kishor
On 6/18/07, Jeff Godfrey <[EMAIL PROTECTED]> wrote: Not seeing this on the list 1.5 hrs after posting, I thought I'd try again. Sorry if this is a duplicate... Jeff = Hi All, I have a table which contains (among other things), a "name" column and a "version" column (a software asset

Re: [sqlite] SQL query help...

2007-06-08 Thread Jeff Godfrey
- Original Message - From: "Trey Mack" <[EMAIL PROTECTED]> To: Sent: Friday, June 08, 2007 1:08 PM Subject: Re: [sqlite] SQL query help... Here's what I tried, which didn't work... select name, substr(name,1,length(name)-3) as zone, substr(name,length(n

Re: [sqlite] SQL query help...

2007-06-08 Thread Trey Mack
Here's what I tried, which didn't work... select name, substr(name,1,length(name)-3) as zone, substr(name,length(name)-2,2) as location, max(thick) - min(thick) as diff from plypoint where diff > 0.0005 group by zone,location That causes a "misuse of aggregate" error. select name, substr(name,

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:- > >