Re: [SQL] Tough Problem -- Record Checkouts

2006-02-17 Thread Greg Stark
"Alfred" <[EMAIL PROTECTED]> writes: > CO| N > --+--- > 0 | 15-59 > 1 | 0, 16-59 > 2 | 0-1, 17-59 > 15| 0-14, 30-59 > 16| 0-15, 31-59 > 30| 0-29, 45-59 > 31| 0-30, 46-59 > 45| 0-44 > 46| 1-45 >

Re: [SQL] view of weekly data

2006-02-17 Thread Greg Stark
"Ding Xiangguang" <[EMAIL PROTECTED]> writes: > Hi, friend, > > Suppose there is table of daily transaction data with 5 fields, > > time(date), open(float8), high(float8), low(float8), close(float8) > > Is it possible to create a view of weekly data, i.e. open is the first > day'open, high is t

[SQL] view of weekly data

2006-02-17 Thread Ding Xiangguang
Hi, friend, Suppose there is table of daily transaction data with 5 fields, time(date), open(float8), high(float8), low(float8), close(float8) Is it possible to create a view of weekly data, i.e. open is the first day'open, high is the highest of the week, low is the lowest of the week, close

[SQL] SELECT on a to-be-determined table

2006-02-17 Thread garhone
Hi, I'm a new at this. So please forgive if I mess up. Also, if there is already a reference/tutorial somewhere, feel free to point me to it. Here's my situation: db=# select * from projects; projid | projname +-- 1 | cars 2 | houses 3 | pets (3 rows) db=# sele

[SQL] passing array(java) to postgre sql function

2006-02-17 Thread bond
Hi All, in postgreSql, i have written a function which accepts a String array and inserts the contents to DB. when i tested that function by passing the values like: SELECT TEST_ARRAY('{xxx,,,ww}'); where TEST_ARRAY is my function name. the records get inserted correctly. But now th

Re: [SQL] Trigger/Sequence headache

2006-02-17 Thread rlee0001
Stephen, You don't need to use a seperate batch to clean up the table. As Stephan pointed out, you can call nextval after you determine that the new row isn't a duplicate. In case you misunderstood what Stephan had suggested let me try to explain what is happening. When PostgreSQL receives an IN

[SQL] Postgres for Dummies - a new request

2006-02-17 Thread Nalin Bakshi
Hi!    I have postgres installed in my machine and have a simple task to do. Step1) Fetch all the tables in the Database with name staerting with "AA" Step2) On each table you get fire a simple SQL query:     select * from ; Step3) Right these into a flat file. I have to carry out all th

[SQL] ORDER BY with LTREE

2006-02-17 Thread Axel Straschil
Hello! Im working with the ltree [1] datatype and have labels that can not used directly in ltree and a want to get a tree like strukture ordered by the labels. IE, I've got a table CREATE TABLE t ( treeLTREE, label TEXT ); and data like treelabel ---

[SQL] Btrieve to PostgreSQL

2006-02-17 Thread Adam Alkins
Hey, Been looking around to do this for a while, haven't gotten concrete information. I'm interested in taking data from Peachtree Accounting 2003 (Which is stored Btrieve DAT files) and importing them into a Postgres SQL database. I have looked around on the net about this, but haven't gotten any

[SQL] Tough Problem -- Record Checkouts

2006-02-17 Thread Alfred
Imagine a library of books. Each book is a record. The library is the table. A user may check out a book and the shelf space it once occupied will store the minute that the user checked the book out. Every 5 minutes, a magical librarian walks through the library and when a book has been checked out

Re: [SQL] two count columns?

2006-02-17 Thread Greg Stark
Jan Danielsson <[EMAIL PROTECTED]> writes: > select from_ip, count(from_ip) as entries, count(select * from log where > ...) as tot_entries, max(ts)::timestamp(0) as last_access from log where > to_port=22 and direction='in' group by from_ip select from_ip, count(from_ip) as entries,

Re: [SQL] two count columns?

2006-02-17 Thread Tom Lane
Jan Danielsson <[EMAIL PROTECTED]> writes: >So the only thing I'm missing is the total number of log entries > matching the from_ip, but that's where I'm stuck. My instinct is to try > to use subqueries: > select from_ip, count(from_ip) as entries, count(select * from log where > ...) as tot_e

[SQL] two count columns?

2006-02-17 Thread Jan Danielsson
Hello all, I have written a small firewall, and sshd, logging system which uses postgresql for storing the logs. The table that stores the firewall logs has, among other columns, from_ip, port and a timestamp. I want to construct a query which returns the columns: from_ip | port 22 entrie

Re: [SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-17 Thread Owen Jacobson
That usually indicates that, for whatever reason, plpgsql.so is from a different version of PostgreSQL than the database server. If you installed PostgreSQL from source, make sure you configured the server to look in the same lib dir as its libs were installed to; if you've installed from packa

Re: [SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-17 Thread Michael Fuhr
On Fri, Feb 17, 2006 at 04:07:28PM -0500, Henry Ortega wrote: > Is there a real quick way to do a query that will show me all the dates > given a startdate and an end date? You could use generate_series(), which is built-in since 8.0 and easily written in earlier versions. SELECT date'2006-02-01'

Re: [SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-17 Thread Owen Jacobson
Henry Ortega wrote: (question about set of all days between two dates) I don't know of a builtin way to do it off the top of my head, but it's a pretty simple function to write: create function days (start date, finish date) returns setof date as $$ declare curdate date; begin curdate := st

[SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-17 Thread Henry Ortega
Is there a real quick way to do a query that will show me all the dates given a startdate and an end date?Given: 02-01-2006 and 02-28-2006it should give me:02-01-200602-02-2006..02-27-2006 02-28-2006Can this be done by a built-in function perhaps?