VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
database query Posted by meherzad4u on 11 May 2010 at 9:17 AM
tables in access

car (carno Primary key ,name ,type ,cost ,qty ,remark )
sales(carno ,noofcars ,date )

1.print the cars which are fast moving cars i.e fastest selling cars.

pl show me query in access to find fastest selling cars.


select * from car where carno=(select carno from sales where sum(num)=(select max(sum(num)) from sales group by carno) group by carno)


Report
Re: database query Posted by seancampbell on 11 May 2010 at 10:51 AM
SELECT Car.*, B.Qty FROM
(SELECT Carno, SUM(Qty) AS Qty FROM Sales GROUP BY CarNo) AS B
INNER JOIN Car ON B.CarNo = Car.CarNo
ORDER BY B.Qty Desc

This will return all of the car's and their respective total sales in order of Most sold to least sold. The first record should be the most Quantity sold car.
-Sean
Report
Re: database query Posted by meherzad4u on 11 May 2010 at 9:57 PM
thanks bro!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.