| Author |
Topic |
|
kiri
Starting Member
38 Posts |
Posted - 2008-02-20 : 12:43:54
|
| create procedure salepasSelect Distinct sum(vs.totsales) as Totalsales, vs.docdate,vs.itemnmbr,p.section_id From psection P inner join ccode C on C.indx = P.indx and p.section_id=c.section_id inner join saleview vs on vs.item = p.item group by vs.docdate,vs.itemnmbr,p.section_id order by vs.item,vs.docdateendi m getting output:Totalsales docdate item section_id---------------------------------------------------------100.000 1/25/2008 R89 7100.00 1/25/2008 R89 105100.00 1/25/2008 R89 44 i want output like:Totalsales docdate item ----------------------------------------- 100.000 1/25/2008 R89 i m not selecting p.section_id and i m using distinct and not joining on section_id then also i m geting 3rows instead of 1Totalsales docdate item -------------------------------------------- 100.000 1/25/2008 R89 100.00 1/25/2008 R89 100.00 1/25/2008 R89 can anybody help me to get it?thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-20 : 12:48:19
|
| remove the section_id from group by and try |
 |
|
|
kiri
Starting Member
38 Posts |
Posted - 2008-02-20 : 12:56:09
|
| i did like this:create procedure salepasSelect Distinct sum(vs.totsales) as Totalsales, vs.docdate,vs.itemnmbrFrom psection Pinner join ccode Con C.indx = P.indx inner join saleview vson vs.item = p.itemgroup by vs.docdate,vs.itemnmbrorder by vs.item,vs.docdateendstill giving me same 3rows as resultset..instead of one..don't know why? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-21 : 01:14:10
|
| TrySelect sum(totsales) as totsales ,docdate,itemnmbr from(Select Distinct vs.totsales as Totalsales, vs.docdate,vs.itemnmbrFrom psection Pinner join ccode Con C.indx = P.indx inner join saleview vson vs.item = p.item) as tgroup by docdate,itemnmbrorder by item,docdateMadhivananFailing to plan is Planning to fail |
 |
|
|
kiri
Starting Member
38 Posts |
Posted - 2008-02-21 : 08:53:12
|
| it gives me error like:The multi-part identifier "vs.itemnmbr" could not be bound.The multi-part identifier "vs.docdate" could not be bound. |
 |
|
|
kiri
Starting Member
38 Posts |
Posted - 2008-02-21 : 08:56:03
|
| Select sum(t.totsales) as totsales ,t.docdate,t.itemnmbr from(Select Distinct vs.totsales as Totalsales, vs.docdate,vs.itemnmbrFrom psection Pinner join ccode Con C.indx = P.indx inner join saleview vson vs.item = p.item) as tgroup by t.docdate,t.itemnmbrorder by t.itemnmbr,t.docdateits not giving me errorbut still not giving correct results |
 |
|
|
kiri
Starting Member
38 Posts |
Posted - 2008-02-21 : 09:02:36
|
| thanks a lot!!!madhivanan,but i m getting output:Totalsales docdate item section_id---------------------------------------------------------100.000 1/25/2008 R89 7100.00 1/25/2008 R89 105100.00 1/25/2008 R89 44 i want output like:Totalsales docdate item ----------------------------------------- 100.000 1/25/2008 R89 i think to use condition like - when item is starting with any character - a,b,c...then result will be one row...totalsales ..docdate..itembut don't know how to use this condition?can anybody help me to figure this out?thanks a lot!! |
 |
|
|
kiri
Starting Member
38 Posts |
Posted - 2008-02-21 : 09:51:22
|
| finally, got the correct results..one row in outputSelect t.totsales as totsales ,t.docdate,t.itemnmbr from(Select Distinct vs.totsales as Totalsales, vs.docdate,vs.itemnmbrFrom psection Pinner join ccode Con C.indx = P.indx inner join saleview vson vs.item = p.item) as torder by t.itemnmbr,t.docdatethanks madhivanan for ur help.thank you |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-22 : 01:11:41
|
quote: Originally posted by kiri finally, got the correct results..one row in outputSelect t.totsales as totsales ,t.docdate,t.itemnmbr from(Select Distinct vs.totsales as Totalsales, vs.docdate,vs.itemnmbrFrom psection Pinner join ccode Con C.indx = P.indx inner join saleview vson vs.item = p.item) as torder by t.itemnmbr,t.docdatethanks madhivanan for ur help.thank you
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|