Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to select top 10 product from my database.
i want to design crystal report on the behalf of my this query.
my employ need top 10 product which sale in current month.
but i dont know how can i find.
\plz help out me
Posted
Comments
Bala Selvanayagam 30-Sep-11 6:17am    
Can you please give your database structure, only the important filds involved in the above and how do you decide top sales ? ( volume wise / monitory wise)
prince_rumeel 30-Sep-11 6:34am    
yes sure i m giving you my database field voucherno,entrydate,transectiondate,saleman,itmcode,itmname,cash,aprtycode,issue_qty,amount,given_t0,balance,itm_part,total_amount

these are my fields,
i want to get top 10 product
Bala Selvanayagam 30-Sep-11 7:25am    
thanks and let me know whether my solution worked for you ?

It's not as simple as that:
SQL
SELECT TOP 10 * FROM myTable
Will return you the first ten items in the table, but only you can decide what makes them the ones you want. You probably want some combination of WHERE clause (to ensure that the month is correct) and ORDER BY clause (to organise them properly).

But only you know what makes a product "top ten". Is it number of units? Total value? Units per salesman? Or what.

Try it in SQL Server Managment Studio. and see what you get...
 
Share this answer
 
Comments
prince_rumeel 30-Sep-11 7:10am    
i m giving you my database field voucherno,entrydate,transectiondate,saleman,itmcode,itmname,cash,aprtycode,issue_qty,amount,given_t0,balance,itm_part,total_amount

these are my fields,
i want to get top 10 product
sachin10d 30-Sep-11 7:12am    
select top 10 voucherno,entrydate,transectiondate,saleman,itmcode,itmname,cash,aprtycode,issue_qty,amount,given_t0,balance,itm_part,total_amount
from myTable
prince_rumeel 30-Sep-11 7:26am    
bro i dont wana get order wise 10 product i want those products which have more much sale then others.
those products which have batter value in market and everyone buy that product.
CREATE PROCEDURE spTopProducts	
AS
BEGIN
	
	SET NOCOUNT ON;
	
	select top 10 SUM(issue_qty) issue_qty,itmcode into #temp
	from tblSales 
	group by itmcode
	order by 1
	
	select *
	from tblProducts
	where itemcode in (select itemcode from #temp)
	

END


This should help and my assumptions are

* Top 10 products are based on the volume sold
* You have a seperate table for products which you want to retrieve for the reporting ?
 
Share this answer
 
Comments
prince_rumeel 30-Sep-11 7:31am    
but bro i m using vb.net
so plz give me solution according to that..plz
Bala Selvanayagam 30-Sep-11 7:52am    
hi prince_rumeel,

This is at SQL SERVER level and you can call this into your report on vb.net.
prince_rumeel 30-Sep-11 7:54am    
thanks alot bala selvanayagam

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900