Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / PowerBuilder Новый топик    Ответить
 PB Select TOp 50 Rows  [new]
SvetaSh
Member

Откуда:
Сообщений: 147
Вот проблема:
задача состоит в том чтобы Select top 50 rows, с наибольшим qty_received.
Вот что я имею, so far:
SELECT purchase_order.Id,
purchase_order.type_Sym,
purchase_order.oid,
purchase_order.category_Sym,
purchase_order.Description,
purchase_order.Created_Date,
purchase_order.Status_Sym,
purchase_order.Status_Date,
purchase_order.Due_Date,
purchase_order_data.serial_number,
Item_Master.id,
Item_Master.description,
purchase_order_Data.qty_received,
/*'qty' = (select sum(purchase_order_data.qty_received) from purchase_order_data where po_oid = purchase_order.oid ),
*/'date' = Dateadd(month, -12, getutcdate())
FROM purchase_order ,
purchase_order_data,
Item_Master

WHERE ( purchase_order_data.PO_oid = purchase_order.oid ) and
( purchase_order_data.Item_Oid = Item_Master.oid ) and
purchase_order.Created_Date >= Dateadd(month, -12, getutcdate()) and
purchase_order.status_sym = 'closed'

I grouped per Item_Master.id and sum the qty_received in DW.
It won't let me sort by the Compute field and I need to display only top 50 ( largetst qty_received rows.

Огромное спасибо всем за помоSELECT purchase_order.Id,
purchase_order.type_Sym,
purchase_order.oid,
purchase_order.category_Sym,
purchase_order.Description,
purchase_order.Created_Date,
purchase_order.Status_Sym,
purchase_order.Status_Date,
purchase_order.Due_Date,
purchase_order_data.serial_number,
Item_Master.id,
Item_Master.description,
purchase_order_Data.qty_received,
/*'qty' = (select sum(purchase_order_data.qty_received) from purchase_order_data where po_oid = purchase_order.oid ),
*/'date' = Dateadd(month, -12, getutcdate())
FROM purchase_order ,
purchase_order_data,
Item_Master

WHERE ( purchase_order_data.PO_oid = purchase_order.oid ) and
( purchase_order_data.Item_Oid = Item_Master.oid ) and
purchase_order.Created_Date >= Dateadd(month, -12, getutcdate()) and
purchase_order.status_sym = 'closed'
Спасибо за помощь всем
23 мар 06, 19:42    [2483554]     Ответить | Цитировать Сообщить модератору
Все форумы / PowerBuilder Ответить