Hi Friends,
my table is:
create table tab
(
ref_group,
product,
qty
)
insert into tab(ref_group,product,qty)
values ('Milk Produtcs','Curd','25')
insert into tab(ref_group,product,qty)
values ('Milk Produtcs','Butter','05')
My expecting O/P:
groupProduct product sales free
Milk Products Butter 0 05
here i wanna show lowest product value from group how to make a code?
Jignesh TrivediPosted Jan 22, 2014, 7:38 AM
hi,
agree with Biswa answer but where can we get the sale column data?
and also other problem with the query is there are different name for product
if you sale data is always 0 then
try...
select A.ref_group,p.product, 0 as sales,free from (
select ref_group, min(qty) as free
from tab
group by ref_group) A
inner join tab p on p.ref_group = a.ref_group and p.qty = a.free
hope this will help you.
Biswa Pujarini MohapatraPosted Jan 22, 2014, 4:25 AM
Biswa Pujarini MohapatraPosted Jan 22, 2014, 4:24 AM
Rocky RockyPosted Jan 22, 2014, 3:57 AM
The highest value in group item is sales remaining items (i.e
Group Product Sales Free
Milk Products Curd 25 0
These already done my code
My need Is
bill Group Product Sales Free
24 Milk Products Butter 0 05
I.e to neglect the highest value in group display lowest like above
Jaganathan BantheswaranPosted Jan 22, 2014, 3:50 AM
How do you calculate sales & free values?
Rocky RockyPosted Jan 22, 2014, 3:48 AM
Jaganathan BantheswaranPosted Jan 22, 2014, 3:36 AM
I dont know the calculation for free & sales, still i can assume & give you the solution,
select top 1 ref_group as 'Group Product', product as 'Product', '0' as 'sales', qty as 'free' from tab
order by cast(qty as int) asc