December 19, 2005 at 8:59 am
I have 2 database tables like Ordermaster and Orderdetails.
In Ordermaster I have columns OrderId, OrderNo,SS_Name
In Orderdetails I have columns OrderId, SS_Amount,SS_OrderBy
The OrderId column is primary key in Ordermaster and a foreign key in Orderdetails
Now I am trying to build a query which would give me a distinct list of all OrderId and OrderNo where the sum of SS_Amount for an orderid in Orderdetails = 100
Any help...Thanks
December 19, 2005 at 9:21 am
select
o.orderid
, o.orderno
, sum( ssamount)
from ordermaster o
inner join orderdetails od
on o.orderid = od.orderid
group by
o.orderid
, o.orderno
having sum( od.ssamount) = 100
December 19, 2005 at 9:28 am
select o.orderid, o.orderno sum(od.ssamount)
from orders o ,orderdetails od
where o.orderid = od.orderid
group by o.orderid, o.orderno
having sum(od.quantity) = 100
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply