Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-17 Thread David Bicking
On Mon, 2009-08-17 at 15:05 -0700, Leo Freitag wrote: > David Bicking-2 wrote: > > > > As written, you were selecting any record with the correct date > > regardless of Ensemble or Steuck. > > > > David > The following seem to work: > > SELECT * FROM tblZO_Haupt AS hpt > WHERE > hpt.zo_tblEnsem

Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-17 Thread Leo Freitag
David Bicking-2 wrote: > > As written, you were selecting any record with the correct date > regardless of Ensemble or Steuck. > > David > The following seem to work: SELECT * FROM tblZO_Haupt AS hpt WHERE hpt.zo_tblEnsemble = AND hpt.zo_tblStueck = ... AND hpt.datum = ( SELECT MAX(hp

Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-12 Thread David Bicking
On Wed, 2009-08-12 at 07:02 -0700, Leo Freitag wrote: > > I modified the code a get the following results. Unfortunetly only a little > more as expected: > > DROP TABLE 'tblZO_Haupt'; > CREATE TABLE 'tblZO_Haupt' ('id' INTEGER PRIMARY KEY, 'zo_tblEnsemble' > INTEGER, 'zo_tblSaenger' INTEGER, 'zo

Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-12 Thread Leo Freitag
Wes Freeman wrote: > > You were using the outside table alias in the subquery: > > (...) > > might work a little more as expected. > > I modified the code a get the following results. Unfortunetly only a little more as expected: DROP TABLE 'tblZO_Haupt'; CREATE TABLE 'tblZO_Haupt' ('id' I

Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-12 Thread Wes Freeman
You were using the outside table alias in the subquery: SELECT * FROM tblZO_Haupt AS hpt WHERE hpt.datum = ( SELECT MAX(hpt_sub.datum) FROM tblZO_Haupt AS hpt_sub WHERE hpt_sub.zo_tblSaenger = hpt.zo_tblSaenger AND hpt_SUB.zo_tblEnsemble = 1 AND hpt_SUB.zo_tblStueck = 1 AND h

Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-12 Thread Leo Freitag
P Kishor-3 wrote: > > On Mon, Aug 10, 2009 at 2:25 PM, Leo Freitag > wrote: > > sqlite> SELECT * FROM haupt WHERE datestamp = (SELECT Max(datestamp) > FROM haupt WHERE "group" = 1 AND song = 1); > 3|1|2|1|11|2009-08-04 > sqlite> > > Although, I would *seriously* advise you to reconsider naming

Re: [sqlite] Problems with max(datestamp) in subquery

2009-08-10 Thread P Kishor
On Mon, Aug 10, 2009 at 2:25 PM, Leo Freitag wrote: > Hello, > > in table haupt I store information about group, singer, song, voice and > datestamp. > > [CODE] > CREATE TABLE 'haupt' ('id' INTEGER PRIMARY KEY, 'group' INTEGER, > 'singer' INTEGER, 'song' INTEGER, >  'voice' INTEGER, 'datestamp' TEX

[sqlite] Problems with max(datestamp) in subquery

2009-08-10 Thread Leo Freitag
Hello, in table haupt I store information about group, singer, song, voice and datestamp. [CODE] CREATE TABLE 'haupt' ('id' INTEGER PRIMARY KEY, 'group' INTEGER, 'singer' INTEGER, 'song' INTEGER, 'voice' INTEGER, 'datestamp' TEXT); INSERT INTO "haupt" VALUES(1, 1, 1, 1, 11, '2009-08-01'); INSE