Connecting Tech Pros Worldwide Help | Site Map

What is SQL Query?

Newbie
 
Join Date: Jul 2007
Posts: 6
#1: 4 Weeks Ago
I am using VB6.0 and MS Access

I have 4 tabel

Table Name Field Name

1 – Product Item_Name

2 – Purchase Piece_No
3 – Invoice Itm_Qty These all have Field Name ( Item_Name )
4 – Refund Itm_Qty

Out Put I want is

Item_Name Pur (Piece_No) Invo(Item_Qty) Ref(Itm_Qty) Stock

ABC 123 300 200 50 50

KKK 02 100 20 10 70


How can I do this ?

Plz Help

Crystal Tech
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,505
#2: 4 Weeks Ago

re: What is SQL Query?


What is the relation between these tables ?

You need to join the tables to get the desired result.
Newbie
 
Join Date: Jul 2007
Posts: 6
#3: 4 Weeks Ago

re: What is SQL Query?


I tried following query but its giving me wrong total
''''''''''''''''''''''''''''''''''''''
SELECT Prd.Item_Name, Sum(P.Piece_No) AS PStock, Sum(D.Itm_Qty) AS SoldStock, Sum(R.Itm_Qty) AS RefStock, Sum(P.Piece_No)-Sum(D.Itm_Qty)-Sum(R.Itm_Qty) AS Avl_Stock
FROM Refund_Detail AS R, (Product AS Prd INNER JOIN Purchase_Detail AS P ON Prd.Item_Name = P.Item) INNER JOIN Detail_Description AS D ON Prd.Item_Name = D.Item
WHERE (((Prd.Item_Name)=[P].[Item] And (Prd.Item_Name)=[d].[Item]))
GROUP BY Prd.Item_Name;
Reply