Re: [SQL] help with to_date and to_char

2004-10-19 Thread lorid
Thanks Thomas it worked great ,even when I put in the var - when_month
:)
Lori
Thomas F.O'Connell wrote:
There might be a better way, but this should do what you want. And I 
think that you can safely replace '05' with when_month.

select to_char( to_date( '05' || '/' || to_char( current_date, 
'DD/' ), 'MM/DD/' ), 'MON' );

-tfo
--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005
On Oct 12, 2004, at 7:20 PM, Lori wrote:
Im trying to do something very simple
I have a field called when_month (integer )
so I want to get the month name for the integer
this comes close to what I want
update mytable set myfield=to_char(current_timestamp,'MON');
the result is myfield is set to OCT
which is close to what I want but when I try to use a variable
update mytable set myfield=to_char(when_month,'MON');
or a char with value of '05' or '5'
update mytable set myfield=to_char('05','MON');
get error:
update mytable set myfield=to_date(when_month,'MON');
update mytable set myfield=to_char('05','MON');
as well as
update mytable set full_month= to_date('01/'05'/2004','DDMON');
all get errors
Please can anyone help?
---(end of broadcast)---
TIP 8: explain analyze is your friend

---(end of broadcast)---
TIP 8: explain analyze is your friend

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [SQL] Finding duplicated values

2004-10-21 Thread lorid




Kent Anderson wrote:

  
  
  I
have a few tables that have duplicated values from an import from a
different database. I have two keys I tried to set as primary and got
an error 
  ERROR: 
could not create unique index
DETAIL:  Table contains duplicated values.
   
  Is
there some join I can use to compare the hmhmkey, wmwmkey pairs against
the table to find duplicate values? Each pair key should be unique but
the old database was less than normalized.
   
  I was
trying to use the code below but it returned no rows.
   
  SELECT
hmhmkey, wmwmkey 
FROM   exceptions
EXCEPT
SELECT hmhmkey, wmwmkey 
  FROM 
exceptions;
   
  Any
suggestions?
   
  Kent Anderson
  EZYield.com
  407-629-0900
  www.ezyield.com
   
  
  This electronic message transmission
contains information from the Company that may be proprietary,
confidential and/or privileged. The information is intended only for
the use of the individual(s) or entity named above.  If you are not the
intended recipient, be aware that any disclosure, copying or
distribution or use of the contents of this information is prohibited. 
If you have received this electronic transmission in error, please
notify the sender immediately by replying to the address listed in the
"From:" field.
   

**
This might do it... 
If you do this on the table that had duplicates you wont need to join
select count(hmhmkey),count(wmwmkey) from 
exceptions group by hmhmkey,wmwmkey having count(hmhmkey) >1 or
having count(wmwmkey) >1;  






Re: [SQL] 'show databases' in psql way?

2004-11-02 Thread lorid
\z   will list the tables in the dbase
\d tablename will list the columns in the table
-
Erik Wasser wrote:
Hi list,
how can I list the databases in a postgresish way? I know about the '-l' 
switch of 'psql' but is there a DBI/SQL-query way? I don't want to call 
an external program only to list the databases. I've googled about this 
problem but I only found the '-l'-way to this this.

Ideas? Solutions?
 


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faqs/FAQ.html


[SQL] getting back autonumber just inserted

2005-02-03 Thread lorid
I could have sworn I kept a copy of prior emails that discussed how to 
get back a value that was just inserted into a autonumber (or in 
postgresql case a sequence number)

any help will be appreciated
thanks
Lori

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faq