Re: SQL syntax help needed
От | Björn Lundin |
---|---|
Тема | Re: SQL syntax help needed |
Дата | |
Msg-id | 20020104142556.056e376a.bjorn.lundin@swipnet.se обсуждение исходный текст |
Список | pgsql-sql |
On Thu, 3 Jan 2002 16:07:30 -0800 "Chris Sypolt" <csypolt@onlinemetals.com> wrote: > Sorry - wasn't thinking. Well it happens to me too... This migth do it.. Select orders.*, shipments.* from orders,shipments where orders.orderid = shipments.orderid and ShipDate(orders.orderdate) <= shipments.shipdate; You then need a function (in plpg/Sql) to get the correct shipdate for an order. (In ada) function Shipdate(aDate : in Date) return date is begin case Weekday(aDate) is when Mon..Fri => return aDate; when Sat => return aDate + 1; when Sun => return aDate + 2; end case; end ShipDate; You also need a function Weekday, to determine what day of week a given date is. Zeller's Congruence is your friend here. Look at John English's 'Ada 95: the Craft of Object-Oriented Programming' chapter 4 (http://www.it.brighton.uk/staff/je/adacraft/ch04.htm) That shouldn't be too hard to translate to plpg/Sql. There is perhaps easier ways to do this, but this is what I've come up with. /Björn
В списке pgsql-sql по дате отправления: