Re: [SQL] function returning a cursor and a scalar

2009-07-13 Thread Alvaro Herrera
Surajit Bhattacharjee wrote: > I am new to Postgresql and am trying to write a function which will do a > search and return the first page of results along with the total number > of matches. How can I make my function return a cursor AND a scalar - > can I do the scalar as an OUT param and then ma

Re: [SQL] simple join is beating me

2009-07-13 Thread Oliveiros
Oh, I actually thought that it was the behavior you wanted, Gary. On the example you supplied you have an order on June , the 29th and it doesn't appear on the result you showed. You wanted this row do appear as an NULL delivery? Just try replacing the RIGHT JOIN by FULL JOIN. This will cause al

Re: [SQL] simple join is beating me

2009-07-13 Thread Hartman, Matthew
> From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Gary Stainburn > Sent: Monday, July 13, 2009 9:12 AM > > If a date exists where we have orders but no deliveries the row does not > appear. > I have tried doing a union to link the two selects together, b

Re: [SQL] simple join is beating me

2009-07-13 Thread Gary Stainburn
Hi Oliveiros, Thank you for this. However, this does not give me what I want. If a date exists where we have orders but no deliveries the row does not appear. I have tried doing a union to link the two selects together, but i still cannot get anything to work. Gary On Monday 13 July 2009 12:

Re: [SQL] simple join is beating me

2009-07-13 Thread Oliveiros
Howdy, Gary, I have not the database in this computer, so I cannot test the sql I'm sending you, but if you do an outer join won't it result in what you need? Maybe I am not reaching what you want to do... SELECT deliveryQuery.o_date , orders, delivery FROM (/* ur first query here */) ordersQuery

[SQL] simple join is beating me

2009-07-13 Thread Gary Stainburn
hi folks i have the following: select o_ord_date as o_date, count(o_id) as orders from orders where o_de_id in (5,6) and o_ord_date > CURRENT_DATE-'1 month'::interval group by o_ord_date order by o_date desc and select o_act_del_date as o_date, count(o_id) as delivery from orders