Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Osvaldo Kussama
2011/2/11, Aaron Burnett : > > Hi, > > I'm just drawing a blank entirely today and would appreciate some help on > this. > > The long and short; there are 12 distinct activities that need to be queried > on a weekly basis: > > SELECT count(activity_id), activity_id > FROM foo_activity > WHERE creat

Re: [SQL] insert record in remote database

2010-10-24 Thread Osvaldo Kussama
//www.postgresql.org/docs/current/interactive/contrib.html For Ubuntu: with Synaptic Package Manager install postgresql-contrib. >    My Dear, Thanks a lot for you response > > > > On Sun, Oct 24, 2010 at 3:37 AM, Osvaldo Kussama > wrote: >> >> 2010/10/22 Maruti Nandan : >

Re: [SQL] insert record in remote database

2010-10-23 Thread Osvaldo Kussama
2010/10/22 Maruti Nandan : > have any one idea !!! > > postgres db, to insert record in a table of other database through > function!!! > > > u see the dblink , but it just use for select statement i want to > > > when trigger fire i want to insert record in other db > -- >From manual: dblink_ex

Re: [SQL] Is there a conditional string-concatenation ?

2010-10-11 Thread Osvaldo Kussama
2010/10/12 Andreas : >  Hi, > Is there a conditional string-concatenation ? > > I'd like to have an elegant way to connect 2 strings with some 3rd element > between only if there really are 2 strings to connect. > > e.g. > MyCat ( 'John', '_', 'Doe' ) --> 'John_Doe' > while > MyCat ( 'John', '_', '

Re: [SQL] Regexp matching

2010-09-29 Thread Osvaldo Kussama
2010/9/28 Eduardas Kazakas : > Hello, I have some problems using character class matching (e.g. [:alpha:]). > > For example I have a table: > > CREATE TABLE re_test (text_column character varying (50) NOT NULL); > > Notice, that there are some specific characters. > > INSERT INTO re_test VALUES ('A

Re: [SQL] Returning only alphanumeric values from a query

2010-07-26 Thread Osvaldo Kussama
2010/7/26 Enrique Palacios : > HI everyone, > Im new here, this is my first mail and i would like to know how return from > a query only alphanumeric values and these symbols: ().,-% > Something like: > SELECT description FROM products WHERE productid = 5 > RESULT > == > X# PRODUCT %1.0/30(UN)

Re: [SQL] How do I remove selected words from text field?

2010-07-01 Thread Osvaldo Kussama
2010/7/1 Frank Bax : > > Create some tables; then add some data: > > create table t1 (i int, v varchar); > insert into t1 values(1,'A B C D'); > insert into t1 values(2,'B D E F'); > insert into t1 values(3,'G H I J'); > insert into t1 values(4,'E'); > create table t2 (q varchar, z varchar); > inse

Re: [SQL] How do I remove selected words from text field?

2010-06-25 Thread Osvaldo Kussama
2010/6/25 Frank Bax : > I'm not quite sure how to ask for the query I want, so let's start with > data: > > create table t1 (i int, val varchar); > insert into t1 values(1,'A B C D'); > insert into t1 values(2,'B D E F'); > insert into t1 values(3,'G H I J'); > create table t2 (q varchar, z varchar

Re: [SQL] 8.4 versus 8.2 against nonexistent column "name" ...

2010-03-17 Thread Osvaldo Kussama
2010/3/17 James Robinson : > Can anyone shine a light on why 8.4 behaves surprisingly when being queried > for a bogus column "name", but only using qualified table/column references. > > Here's a sample script: > > - > create table foo > ( >        id int, >        x int > ); > > insert into f

Re: [SQL] reading last inserted record withoud any autoincrement field

2009-10-04 Thread Osvaldo Kussama
2009/10/4 mohammad qoreishy > > How can get last inserted record in a table without any autoincrement filed? > I need to  frequently fetch the last inserted record. > If I must use the "Cursor" please explain your solution. > RETURNING clause? http://www.postgresql.org/docs/current/interactive/s

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Osvaldo Kussama
2009/9/17 Gavin McCullagh : > On Thu, 17 Sep 2009, Frank Bax wrote: > >> Gavin McCullagh wrote: >>> SELECT time, to_timestamp(time) AS ts, >>> EXTRACT('months',to_timestamp(time)) FROM mdl_log; >>> ERROR:  syntax error at or near "," >>> LINE 1: ...t time, to_timestamp(time) AS ts, extract('months'

Re: [SQL] Bucketing Row Data in columns

2009-06-25 Thread Osvaldo Kussama
2009/6/25 James Kitambara : > > Hello Mr. Sandeep Bandela, > > I have gone through your scenario and come up with the following solution. > > SELECT USER_ID, CREATE_TIMESTAMP::DATE, SUM(AMOUNT) > FROM ORDERS > GROUP BY USER_ID, CREATE_TIMESTAMP > ORDER BY USER_ID, CREATE_TIMESTAMP; > > Maybe you ne

Re: [SQL] Comparing two tables of different database

2009-04-30 Thread Osvaldo Kussama
2009/4/29 Nicholas I : > >   can anybody me suggest me, how to compare two tables of different > database. > Two PostgreSQL databases: dblink http://www.postgresql.org/docs/current/interactive/dblink.html Distinct DBMS: dbilink http://pgfoundry.org/projects/dbi-link/ Osvaldo -- Sent via pgsql

Re: [SQL] a bit confused about distinct() function

2009-03-29 Thread Osvaldo Kussama
2009/3/29 Tena Sakai : > Hi Everybody, > > I am a bit confused about distinct() function. > > I wrote a simple query like this: > >  select subjectid, markerid, allele1id, allele2id >   from tsakai.mygenotype2 >  where subjectid in (53684, 53688, 53699, 53700, 53704, 53705, 53713, 53714, > 53716, 5

Resp.: [SQL] need help in building a query

2008-11-07 Thread Osvaldo Kussama
2008/11/7, Devil™ Dhuvader <[EMAIL PROTECTED]>: > its like sum up entries of each user in order table backwards (i.e from last > entry to the first) and find the entry that has sum > $500. > If there is some user who didnt even make 500 till now in my shop return the > first date of transaction/ord

Fwd: [SQL] grouping/clustering query

2008-10-27 Thread Osvaldo Kussama
I forgot the list. -- Forwarded message -- From: Osvaldo Kussama <[EMAIL PROTECTED]> Date: Mon, 27 Oct 2008 12:28:57 -0200 Subject: Re: [SQL] grouping/clustering query To: David Garamond <[EMAIL PROTECTED]> 2008/10/24, David Garamond <[EMAIL PROTECTED]>:

Resp.: [SQL] Multi-line text fields

2008-09-23 Thread Osvaldo Kussama
2008/9/23, Craig Ringer <[EMAIL PROTECTED]>: > Mike Toews wrote: >> Hi all, >> >> I have some records that have some multiple lines within a single text >> field. (On top of that, I think I have mixed DOS/UNIX line endings too). >> I'm looking for two functions which can operate on a single field:

Re: [SQL] update with join

2008-04-02 Thread Osvaldo Kussama
2008/4/2, Ivan Sergio Borgonovo <[EMAIL PROTECTED]>: > I've > > create table types( > typeid int, > special boolean not null > ); > > create table methods( > methodid int, > typeid references types(typeid), > ); > > create table orders( > orderid int > ); > > create table order_pay

Re: [SQL] Date and filling issues

2008-03-19 Thread Osvaldo Kussama
2008/3/19, Christopher Crews <[EMAIL PROTECTED]>: > Hi All, > I'm not quite sure how to phrase this, but essentially my company has me > working on some reports and I have some charts associated with the SQL > results. > > My current query is: > > select > transaction_date as date, > sum(sa

Re: [SQL] using copy from in function

2008-03-04 Thread Osvaldo Kussama
2008/3/4, Yura Gal <[EMAIL PROTECTED]>: > I'm trying to automate import data using CORY FROM. For this purpose I > wrote plpgsql function. As my postgres works on windows vista I need > to use E'' syntax for path-to-file. This syntax works fine in SQL > queries like: > COPY table FROM E'path_to

Re: [SQL] subtract a day from the NOW function

2007-06-07 Thread Osvaldo Kussama
--- "Campbell, Lance" <[EMAIL PROTECTED]> escreveu: > Table > > Field "some_timestamp" is a timestamp. > > > > In a "WHERE" statement I need to compare a timestamp > field in a table > "some_timestamp" to now() - one day. > > > > Example: > > > > SELECT some_timestamp WHERE to_char(s

Re: [SQL] error with mor than 1 sub-select

2006-08-22 Thread Osvaldo Kussama
chrisj <[EMAIL PROTECTED]> escreveu: Hi,I am fairly new to PostgreSQL but not to SQL. Is this a bug or alimitation...The first query works fine, but when a second sub-query is added I get asyntax error...psql protocal2 -U p2user << EOF1select * from serv_res SR where serv_key = 10

Re: [SQL] Like with special character

2006-07-18 Thread Osvaldo Kussama
Emi Lu <[EMAIL PROTECTED]> escreveu: I'm using postGre with tables which contain French character >> (?...). Is there a fonction which performs a like in replacing ? >> (e cute) by e ?>> to_ascii() should helps youI got the following error:select to_ascii('ê');ERROR: encoding conversion f