Click to See Complete Forum and Search --> : Can we Use orderby in views


chinni1
02-11-2009, 05:41 AM
Hello

Can we Use orderby clause in views


create view v10 as
SELECT P.product_id AS id,P.Number
as Number,P.name AS name,I.qty_inhouse AS
qty, p.price as price,p.actual_price as
actprice,p.batch_num as batchnum,i.min_qty,(p.actual_price*I.qty_inhouse)as buyprice,(p.price*I.qty_inhouse)as buyprice1,
p.active,p.flag,p.email_list as email,p.def_mail
as def_mailselect ,pod.quantity as availqty,(I.qty_inhouse-pod.quantity)as nqty FROM product_master P, inventory_master I,product_order_details pod,product_orders po WHERE P.inventory=1 AND po.order_id=pod.order_id and pod.product_id=p.product_id and
P.outofseason=0 and po.status=0 and i.inv_id = p.product_id orderby p.product_id

NogDog
02-11-2009, 06:13 AM
I don't know about other DBMS's, but in MySQL:
"ORDER BY is allowed in a view definition, but it is ignored if you select from a view using a statement that has its own ORDER BY."
(From http://dev.mysql.com/doc/refman/5.0/en/create-view.html)