Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Allan Kamau
Thanks Willem for the advise to stick to SQL solutions where possible. A simple SQL solution would be to perform a full out join on the two tables. On Mon, Nov 12, 2012 at 12:13 PM, Willem Leenen wrote: > > My advice: for comparing databases, tables , data etc, don't go scripting > yourself. T

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Allan Kamau
If you would like to compare their contents perhaps this may help. Write a select statement containing the fields for which you would like to compare data for, you may want to leave out fields whose values are provided by default for example fields populated from sequence object and/or timestamp fi

Re: [SQL] how to concatenate in PostgreSQL

2012-03-24 Thread Allan Kamau
On 3/24/12, Andreas Kretschmer wrote: > Rehan Saleem wrote: > >> hi , >> how can we concatinate these lines and execute sql command >> >>set sql = 'select user,username, firstname ' >> set sql += ' lastname, cardno from table1 where userid=' + 5 > > sql = sql || ' bla fasel'; > > ||

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

2009-03-12 Thread Allan Kamau
int last_bit_set_position=0; for(i=0;i0) first_bit_set_position=(8*byte_cnt)+b; else first_bit_set_position=0; PG_RETURN_INT32(first_bit_set_position); } Allan. On Thu, Mar 12, 2009 at 2:53 PM, Allan Kamau wrote: > Hi all, >

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

2009-03-12 Thread Allan Kamau
;; but it seems it will take me a while to figure out bit manipulation. Allan. Allan Kamau wrote: All was well with the code below, apologies to all who read my previous email. The error (an oversight) was on my part. In the "CREATE FUNCTION ..." statement I had FLOAT as the return type

Re: [SQL] Collapsing (select) row values into single text field.

2008-12-10 Thread Allan Kamau
query, but I can not recall the actual syntax. Allan. On Wed, Dec 10, 2008 at 4:45 PM, Filip RembiaƂkowski <[EMAIL PROTECTED]> wrote: > > > 2008/12/10 Allan Kamau <[EMAIL PROTECTED]> >> >> Hi all, >> I would like to concatenate the field values of several rows

[SQL] Collapsing (select) row values into single text field.

2008-12-10 Thread Allan Kamau
Hi all, I would like to concatenate the field values of several rows in a table that meet some similarity criteria based on a the values of some other field (more like a group by). Then I would also like to also include the lowest value of another associated field along. I have a table that

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

2008-08-22 Thread Allan Kamau
magnitude faster than the LENGTH(REGEXP(CAST(myVarBit AS TEXT),'0','','g')) solution. Thanks again TJ and the rest of the team. Allan Allan Kamau wrote: Thank you TJ and everyone else for the advise and the c code. Today I did finally return to the 'number of bi

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

2008-08-21 Thread Allan Kamau
Thank you TJ and everyone else for the advise and the c code. Today I did finally return to the 'number of bits set challenge' and managed to compile and link the nbits c function which went smoothly. However the function does crash my postgres server installation (8.3.3) with a segmentation fa

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

2008-07-26 Thread Allan Kamau
Hi all, Am looking for a fast and efficient way to count the number of bits set (to 1) in a VARBIT field. I am currently using "LENGTH(REGEXP_REPLACE(CAST(a.somefield_bit_code AS TEXT),'0','','g'))". Allan. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] Sequential event query

2008-06-25 Thread Allan Kamau
Hi Steve, Am having difficulties (there is a chance I could be the only one) trying to see how the results you've listed under "I would want to get:" section can be generated from the information you have provided in your implicit problem statement. Please reconstruct your question, show simpl

[SQL] Weeks elapsed to Months elapsed conversion

2008-05-30 Thread Allan Kamau
Hi all, I have a simple question (tried googling but found no answers). How do I convert weeks elapsed into months elapsed? I have data that contains duration in weeks (without any other date values such as year and so on) for example a week value of 14 and I would like to convert the 14 weeks

Re: [SQL] Removing redundant itemsets

2008-03-31 Thread Allan Kamau
hases" in the datasets I may be working with may be large), I was looking for a solution that may take (almost) polynomial time (and resources) and also make use of Postgresql refined and efficient engine. Your solution satisfies these requirements. Thanks. Allan. Craig Ringer wrote: A

[SQL] Removing redundant itemsets

2008-03-31 Thread Allan Kamau
Hi all, I have a list of purchases (market basket) and I would like to select non redundant longest possible patterns by eliminating (creating/populating other table to contain only non redandant itemsets) purchases having item lists which are fully included in at least one other purchase. (Am as