SELECT min(TotalCost) as Cost , RateId from tblCosts group by RateId
RateId Cost
12 20
17 48
2. And then.. (Syntax)
Select * from tblCosts where... (SELECT min(TotalCost) as Cost, RateId from tblCosts group by RateId)....
* Try to use something like ... I have no database now, and no further testing
ishanjrana
create table tblCosts
(
CostId number primary key,
RateId number,
Carrier varchar2(20),
TotalCost number
);
insert into tblCosts
values(1,12,'FedEx',20);
insert into tblCosts
values(2,12,'Ups',25);
insert into tblCosts
values(3,17,'FedEx',50);
insert into tblCosts
values(4,17,'Ups',48);
Query-----------------------------------------------------------------------------------------------------
select * from tblCosts
where TotalCost in
(
select min(TotalCost)
from tblCosts
group by RateId
);
Nearly there...a few to many columns in the query result but still good,
select * from tblcosts AS T1,
(select rateid, min(totalcost) as cost from tblcosts group by rateid) x
where t1.rateid = x.rateid and t1.totalcost = x.cost;
SELECT min(TotalCost) as Cost , RateId from tblCosts group by RateId
RateId Cost
12 20
17 48
2. And then.. (Syntax)
Select * from tblCosts where... (SELECT min(TotalCost) as Cost, RateId from tblCosts group by RateId)....
* Try to use something like ... I have no database now, and no further testing