Re: [SQL] combine SQL SELECT statements into one

2010-02-01 Thread Leo Mannhart
msi77 wrote: > Hi, > > SELECT > (SELECT COUNT(distinct model) FROM inventory WHERE modified >= '2010-02-01') > as count1, > (SELECT COUNT(distinct model) FROM inventory WHERE modified >= '2010-01-20') > as count2, > (SELECT COUNT(distinct model) FROM inventory WHERE modified >= '2010-01-01') >

Re: [SQL] Fwd: conditional rule not applied

2010-01-07 Thread Leo Mannhart
Seb wrote: > Hi, > > Apologies for posting this from postgresql.general, but this failed to > get any follow-ups in that NG. Hopefully someone here can shed some > light on this. [snip] I can give a 'first cut' solution. But I strongly discourage from doing this in a real world application as c

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Leo Mannhart
rawi wrote: > > Leo Mannhart wrote: >> Caveat: If you use the standard sequence generator in hibernate, it is >> not using the postgres-sequence in the "usual" manner. hibernate itself >> caches 50 ID's as sequence numbers by default. This means, hibernat

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Leo Mannhart
rawi wrote: > Hello! > > The subject says it... > > Grails/Hibernate wishes per default one sequence for all tables-PKs and all > PKs as BigInt. > > What would you think about a database with some tens of tables and > incidentally low to moderate insert concurrency spread in about the half of >

Re: [SQL] two records per row from query

2009-08-07 Thread Leo Mannhart
John wrote: [snip] > > I'm sorry I was attempting to simplify the problem. I will attempt to > provide > more info: > > OVERVIEW: > "mytable" contains the dates of the classes a student will attend along with > fields to identify the student (not really it's normalized). One row per > clas

Re: [SQL] two records per row from query

2009-08-06 Thread Leo Mannhart
John wrote: > mytable > pkid > class_date. > sessionid > > select * from mytable > 1 2009/01/01 2101 > 2 2009/01/02 2101 > > I would like an SQL that would produce > > newtable > pkid, > class_date1, > class_date2, > sessionid1, > sessionid2 > > Select * from newtable > > 1 2009/01/01 2009/01/

Re: [SQL] uniqueness constraint with NULLs

2009-06-29 Thread Leo Mannhart
On Mon, 2009-06-29 at 17:08 +1000, Robert Edwards wrote: > A. Kretschmer wrote: > > In response to Robert Edwards : > >> Can anyone suggest a way that I can impose uniqueness on a and b when > >> c is NULL? > > > > Sure, use a functional index: > > > > test=# create table bobtest (a int, b int, c