Re: [SQL] using case to select 'which version to use'

2009-08-20 Thread Rodrigo E . De León Plicet
On Thu, Aug 20, 2009 at 10:17 AM, Gerardo Herzig wrote: > Hi all. I have 2 functions , which returns the same columns, but with > tottaly different logics. I want to wrap it with a third function, who > will receive a boolean argument to decide wich sub-function have to use. > > I want to use case,

Re: [SQL] SQL syntax I've been unable to figure out....

2008-12-25 Thread Rodrigo E. De León Plicet
2008/12/25 Karl Denninger : > Assuming a table containing: > > name text > address text > uri text > > I wish to run a query that will return those rows where: > > ("name" is not null) AND (distinct) (uri is the same for two or more entries > AND name is different between the two entries)) > > Exam

Re: [SQL] [GENERAL] date range query help

2008-11-19 Thread Rodrigo E. De León Plicet
On Wed, Nov 19, 2008 at 10:03 PM, novice <[EMAIL PROTECTED]> wrote: > sorry I get nothing :( Of course not. None of the dates you gave in the example overlap. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pg

Re: [SQL] Weeks elapsed to Months elapsed conversion

2008-05-30 Thread Rodrigo E. De León Plicet
On Fri, May 30, 2008 at 4:21 AM, Allan Kamau <[EMAIL PROTECTED]> wrote: > Expected tests may be: > 14 weeks yields 3 months. > 1 weeks yields 0 months. Assuming 4 week months: SELECT 14 / 4 AS "3 months", 1 / 4 AS "0 months" 3 months | 0 months --+-- 3 |0 (1 row)

Re: FW: Re: [SQL] Part 1 of several - Converting a varchar to an interval

2008-03-26 Thread Rodrigo E. De León Plicet
On Wed, Mar 26, 2008 at 5:45 PM, Shawn <[EMAIL PROTECTED]> wrote: > obviously it doesn't like the extra single quotes around the 1 msec. Any > suggestions for a work around? Use dollar quoting, e.g.: create or replace function dur_interval_msec(int) returns interval as $$ select ($1 * interval

Re: [SQL] Date and filling issues

2008-03-19 Thread Rodrigo E. De León Plicet
On 3/19/08, Christopher Crews <[EMAIL PROTECTED]> wrote: > and what I'm trying to do is fill in the missing dates with sales values of 0. create or replace function gen_dates(sd date, ed date) returns setof date as $$ select $1 + i from generate_series(0, $2 - $1) i; $$ language sql immutable; se

Re: [SQL] Composite UNIQUE across two tables?

2008-03-11 Thread Rodrigo E. De León Plicet
On Tue, Mar 11, 2008 at 2:03 PM, Dirk Jagdmann <[EMAIL PROTECTED]> wrote: > For my tests, I have modified your posted schema a bit, to > unify all column names to "name". OT and IMHO, this is not good practice. Column names should be unique and descriptive throughout the entire schema. -- Sent

Re: [SQL] duplicate key violates unique constraint

2008-02-26 Thread Rodrigo E. De León Plicet
On Tue, Feb 26, 2008 at 11:36 AM, Shavonne Marietta Wijesinghe <[EMAIL PROTECTED]> wrote: > BEGIN > SAVEPOINT s1; > ... code here ... > EXCEPTION > WHEN ... THEN > ROLLBACK TO s1; > ... code here ... > WHEN ... THEN > ROLLB

Re: [SQL] String function to Find how many times str2 is in str1?

2008-02-15 Thread Rodrigo E. De León Plicet
On Fri, Feb 15, 2008 at 11:09 AM, Emi Lu <[EMAIL PROTECTED]> wrote: > Str1 = "test test caa dtest testing EndofString"; > Str2 = " "; > > select funcName(Str1, Str2); > > return 5 CREATE OR REPLACE FUNCTION FOOBAR(TEXT,TEXT) RETURNS INT AS $$ SELECT(LENGTH($1) - LENGTH(REPLACE(

Re: [SQL] SQL dealing with subquery

2008-01-15 Thread Rodrigo E. De León Plicet
On Jan 15, 2008 1:04 PM, Bryan Emrys <[EMAIL PROTECTED]> wrote: > In other words, in the sample above, I only want to return: > 'Canada','Ireland',0 > 'Canada','Netherlands',5 Try (untested): SELECT t2.* FROM (SELECT payor FROM treaty_rates WHEREpayee IN ('Netherlands'

Re: [SQL] Limit # of recs on inner join?

2007-12-31 Thread Rodrigo E. De León Plicet
On Dec 31, 2007 1:52 PM, Josh <[EMAIL PROTECTED]> wrote: > Instead, I just want: > > 1 A Cat In The HatDr. Seuss SELECT books.book_id, books.title, (SELECT author_name FROM authors WHERE book_id = books.book_id LIMIT 1) AS author_name FROM books WH