Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kond.mohan
Posting Yak Master
213 Posts |
Posted - 2013-05-04 : 07:06:09
|
hi i am not able getting data in proper order i am executing query on ssms for preparing the repott i am getting loop 49 records i need to get the 7 records.pls explain process SELECT distinct AK.VBELN AS QUOTATION_NUMBER, AK.KNUMV AS DOC_cond ,AP.POSNR AS ITEM,AP.MATNR AS MATERIAL, AP.KWMENG AS ORDERQTY, AP.ZIEME AS UOM, KV2.KWERT AS MRP_VAL, KV3.KWERT AS ASS_VAL FROM KNA1 K INNER JOIN VBAK AK ON AK.KUNNR=K.KUNNR INNER JOIN VBAP AP ON AK.VBELN=AP.VBELN INNER JOIN KONV KV ON AK.KNUMV=KV.KNUMV AND KV.MANDT=AK.MANDT INNER JOIN (SELECT DISTINCT KONV.KWERT,KONV.KNUMV,KONV.MANDT FROM KONV WHERE KSCHL='ZMRP' AND KSCHL IS NOT NULL) KV2 ON KV2.KNUMV=KV.KNUMV AND KV2.MANDT=KV.MANDT inner JOIN (SELECT DISTINCT KONV.KWERT,KONV.KNUMV,KONV.MANDT FROM KONV WHERE KSCHL='ZASS' AND KSCHL IS NOT NULL) KV3 ON KV3.KNUMV=KV.KNUMV AND KV3.MANDT=KV.MANDT WHERE AK.VBTYP='B' AND AK.VBELN='0001400829' AND AP.POSNR=100001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 247.000001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 689.000001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 750.750001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 1059.500001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 4088.500001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 5148.000001400829 0000023315 10 10GREK785-5K 8.000 PIL 380.00 20592.00mohan |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-05-05 : 21:16:42
|
Perhaps you need to use "SUM(KV3.KWERT) AS ASS_VAL" and group by all the other columns in the select list? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-06 : 02:14:16
|
difficult to suggest unless we know how tables are related (it seems to be one to many at the moment) and at what level you need result.Perhaps you could post some sample data to give us clear idea on it.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|