[SQL] Grouping by week

2004-08-06 Thread Caleb Simonyi-Gindele
I'm using SELECT EXTRACT(WEEK FROM trans_date), SUM(tran_amount) ... GROUP BY trans_date and it is being used to group sales results by week. It works really well. What I'm wondering is if I can shift the week from a Mon-Sun articulation(default with Postgre) to a Sun-Sat sequence. I need it

[SQL] contrib/tablefunc crosstab

2004-08-05 Thread Caleb Simonyi-Gindele
Hi, I am using the crosstab function by Joe Conway and I am having a problem that could be my fault but I'm not sure. My query/result is: atc=# SELECT * FROM crosstab('SELECT cli_tran_trans_date, TRIM(dat_staff_code) AS dat_staff_code, SUM(cli_tran_amount) from vetpmardet WHERE cli_tran_trans_da

[SQL] SELECT query/subquery problem

2004-07-20 Thread Caleb Simonyi-Gindele
I'm still trying to isolate issues with my SELECT query. I have a table in my veterinary software which stores my sales transactions. The pertinent columns are dat_staff_code (stores the doctor who gets credit for the sale), sys_tran_number (stores a unique transaction #), cli_credit_adj_trans_no (

[SQL] Group by failing on Null values

2004-07-19 Thread Caleb Simonyi-Gindele
I have a SELECT query that basically adds up my sales, removes credit adjustments (eg. Returns) and gives the net figure.   This is the query: SELECT (SELECT SUM(cli_tran_amount) FROM vetpmardet WHERE cli_credit_adj_trans_no IN (SELECT sys_tran_number from vetpmardet WHERE cli_tran_trans