David Godistei

David Godistei

  • 1.3k
  • 432
  • 1.6k

How to minimized output rows in a query in my Windows Form Application

Jun 24 2024 8:47 AM

Greetings to all.

I am on-building a Windows Form Application where a stored procedure (build on two tables - Stock and Sales) is built on the database server (.mdf). Then, on the client side a form is built to pull data from the stored procedure on the server side.

The following is the SQL language used to build the stored procedure namely, AvailableQty:-

CREATE PROCEDURE [dbo].[AvailableQty]

       @code int = 0    

AS

       SELECT Stock.Category, Stock.ProductName, Stock.Model, Stock.StockQty, Sales.SaleQty FROM Stock, Sales

       WHERE Stock.Code = Sales.Code AND Stock.Code = @code

       RETURN 0

A form was built on the client side. Data were entered in both the stock and sales tables (two entries made in the stock table and three in the sales table) respectively. The AvailableQty form is to pull data per product, from both tables and display the result.

The results displayed were more than expected. I wish to attach here and image as example. There are duplicates of rows that give wrong totals.

Please I will appreciate a solution for my problem.

Thanks


Answers (2)