Re: [SQL] Re: Efficiently determining the number of bits set in the contents of, a VARBIT field

2009-03-12 Thread Allan Kamau
Hi all, I am now looking for a function to return the position of the first position of the left most set bit. And optionally another to return the position of the right most set bit. I have been looking at "http://graphics.stanford.edu/~seander/bithacks.html#OperationCounting"; but it seems

[SQL] Permanent alias for postgresql table

2009-03-12 Thread Marco Lechner
Hi list, I'm searching for a way to create permanent alias for tablenames in postgresql. We are storing various versions of a routable network in postgresql (postgis, pgrouting) and access a certain version with a bunch of php-skripts. We like to use aliases for the "currently used tables" oo be a

Re: [SQL] Permanent alias for postgresql table

2009-03-12 Thread Thomas Kellerer
Marco Lechner, 12.03.2009 13:59: Hi list, I'm searching for a way to create permanent alias for tablenames in postgresql. We are storing various versions of a routable network in postgresql (postgis, pgrouting) and access a certain version with a bunch of php-skripts. We like to use aliases for

Re: [SQL] Permanent alias for postgresql table

2009-03-12 Thread Marco Lechner
Hi Mina, thanks for your answer. I thought about that, but don't views decrease performance, because they are "calculated" on access? Marco On Thu, 12 Mar 2009 13:34:39 + Mina R Waheeb wrote: > Use views, > > mytablev1 and we have a view mytable selecting * from > mytablev1 > and when we

Re: [SQL] Permanent alias for postgresql table

2009-03-12 Thread Joshua Tolley
On Thu, Mar 12, 2009 at 03:26:47PM +0100, Marco Lechner wrote: > Hi Mina, > > thanks for your answer. I thought about that, but don't > views decrease performance, because they are "calculated" > on access? The query gets rewritten a bit, but it's not a big deal. A more important concern might be

Re: [SQL] Permanent alias for postgresql table

2009-03-12 Thread Thomas Kellerer
Marco Lechner, 12.03.2009 15:26: Hi Mina, thanks for your answer. I thought about that, but don't views decrease performance, because they are "calculated" on access? I'm not sure what you mean with "calculated". A view is just a SQL query. There is no difference in executing the SQL query th

[SQL] select count of all overlapping geometries and return 0 if none.

2009-03-12 Thread Duffer Do
Hello all, I have 2 tables locations and user_tracker: locations has 2 columns location_name location_geometry user_tracker has 3 columns user_name user_geometry user_timestamp locations table is coordinates and names of areas of interest. user_tracker basically is an archive of a user's moveme

Re: [SQL] Re: Efficiently determining the number of bits set in the contents of, a VARBIT field

2009-03-12 Thread Allan Kamau
Seems I have a solution based on the code TJ had provided for counting the bits sets, for those interested below are the two functions. #include "postgres.h" #include "utils/varbit.h" #include "fmgr.h" #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif PG_FUNCTION_INFO_V1(last_bit_set); Datum last_

Re: [SQL] Permanent alias for postgresql table

2009-03-12 Thread Lennin Caro
-- On Thu, 3/12/09, Marco Lechner wrote: > From: Marco Lechner > Subject: Re: [SQL] Permanent alias for postgresql table > To: pgsql-sql@postgresql.org > Date: Thursday, March 12, 2009, 2:26 PM > Hi Mina, > > thanks for your answer. I thought about that, but don't > views decrease performance

[SQL] subquery question

2009-03-12 Thread Sebastian Böhm
Hi, I have a table: (date timestamp, id integer, value integer) What Iam trying to do is to get a result that looks like this: day sum_oddsum_even 2009-01-01 656578867 2009-01-02 876785 87667 basically a need to combine these two queries into one: SELECT

Re: [SQL] subquery question

2009-03-12 Thread Bob Henkel
Does this help Here is my test table data. ID;DATE;VALUE 1;"2009-03-13";5 2;"2009-03-13";2 3;"2009-03-11";1 4;"2009-03-11";2 5;"2009-03-11";3 SELECT mydate AS day, SUM(CASE WHEN id % 2 = 1 THEN value END) AS sum_odd, SUM(CASE WHEN id % 2 = 0 THEN value END) AS sum_even FROM xyz GROUP