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 |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2007-07-19 : 09:07:15
|
| hi friends can any body help fo rthe below issue:stock========Item costpen 150pencil 150stockdt=========Item qtypen 10pen 15pencil 10pencil 15for the above two table of stock,stockdt the o/p should come like thisItem cost qty std.costpen 150 25 3750 pencil 150 25 3750 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-19 : 09:26:14
|
[code]SELECT s.Item, s.cost, d.qty, [std.cost] = s.cost * d.qtyFROM stock sINNER JOIN ( SELECT Item, qty = SUM(qty) FROM stockdt GROUP BY Item ) d ON s.Item = d.Item[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|