I have 2 tables
Cash sale
Itemcode itemname qty price value
A1 apple 2 12 24
B1 orange 1 20 20
C2 pinapple 3 30 90
Credit sale
Itemcode itemname qty price value
A1 apple 3 10 30
B1 orange 2 40 80
I want to display
Itemcode itemname qty value
A1 apple 5 54
B1 orange 3 100
C2 pinapple 3 90
How we write tis query plz help?
Loading
Suthish NairPosted Jul 5, 2011, 8:46 AM
select c1.Itemcode ,c1.ItemName
, (c1.qty + isnull(c2.qty, 0)) qty
, (c1.value + isnull(c2.value, 0)) value
from Cashsale c1 left join dbo.Creditsale c2
on c1.Itemcode = c2.Itemcode
Posted Jul 6, 2011, 12:57 AM
Vilas GitePosted Jul 5, 2011, 4:22 AM
HI Shyja
refer : http://www.1keydata.com/sql/sqlouterjoin.htmlhere, nice critical quires for further references...
----------------------------------------------------------------------------------------------------
If this reply hepls your post…then "MARK AS ANSWER"!
Deepthi AravindPosted Jul 5, 2011, 3:43 AM
select CS.ItemCode,CS.ItemName,CS.qty+CR.qty 'Qty',CS.value+CR.value 'Value' from Cashsale CS
left join Creditsale CR
on CS.ItemCode=CR.ItemCode