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 |
|
Deon Smit
Starting Member
47 Posts |
Posted - 2008-08-28 : 10:16:36
|
| HiI am trying to call record by joining 2 tables. Then want to group them and sum the Qty. It seems because it is unique records it won't group and I can't get a total. Please help.Script..select distinct B.batchcartonid, (A.qtyallocated*A.unitprice) as Rand from pickdetail B join orderdetail A on A.orderkey=B.orderkeyand A.ORDERLINENUMBER=B.ORDERLINENUMBERwhere A.qtyallocated > '0' and B.batchcartonid > '0'Script with group that don't work.select distinct B.batchcartonid, (A.qtyallocated*A.unitprice) as Rand from pickdetail B join orderdetail A on A.orderkey=B.orderkeyand A.ORDERLINENUMBER=B.ORDERLINENUMBERwhere A.qtyallocated > '0' and B.batchcartonid > '0'group by B.batchcartonid |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-28 : 10:20:33
|
| show some sample data. without seeing data its difficult to understand why its not working. |
 |
|
|
Deon Smit
Starting Member
47 Posts |
Posted - 2008-08-28 : 10:22:07
|
| BATCHCARTONID RAND------------------------------0000142670 122.760000146415 24.540000146415 48.220000146415 52.610000146415 63.120000146415 67.50000146415 68.040000146415 78.90000146415 87.680000146416 11.790000146416 31.520000146418 36.820000146418 52.610000146418 105.220000146418 157.860000146418 220.980000146419 28.480000146419 34.160000146419 51.280000146419 56.980000146419 68.390000146419 74.090000146419 125.380000146419 159.60000146420 34.160000146420 56.980000146420 85.440000146420 102.60000146420 239.37 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-28 : 10:22:07
|
| Tryselect B.batchcartonid, sum(A.qtyallocated*A.unitprice) as Rand from pickdetail B join orderdetail A on A.orderkey=B.orderkeyand A.ORDERLINENUMBER=B.ORDERLINENUMBERwhere A.qtyallocated > '0' and B.batchcartonid > '0'group by B.batchcartonidMadhivananFailing to plan is Planning to fail |
 |
|
|
Deon Smit
Starting Member
47 Posts |
Posted - 2008-08-28 : 10:22:56
|
| BATCHCARTONID RAND---------------------------0000142670 122.760000146415 24.540000146415 48.220000146415 52.610000146415 63.120000146415 67.50000146415 68.040000146415 78.90000146415 87.680000146416 11.790000146416 31.520000146418 36.820000146418 52.610000146418 105.220000146418 157.860000146418 220.980000146419 28.480000146419 34.160000146419 51.280000146419 56.980000146419 68.390000146419 74.090000146419 125.380000146419 159.60000146420 34.160000146420 56.980000146420 85.440000146420 102.60000146420 239.37 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-28 : 10:27:05
|
| where's pickdetail data? just show 5 rows from each table and result you want to get out of 5 rows. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-28 : 10:27:27
|
| Did you try the query I posted?MadhivananFailing to plan is Planning to fail |
 |
|
|
Deon Smit
Starting Member
47 Posts |
Posted - 2008-08-28 : 10:45:07
|
| Thank You !That Worked. |
 |
|
|
|
|
|