Solved

I want the productid where packageitemid is the min

Posted on 2011-02-25
4
231 Views
Last Modified: 2012-05-11
combine these two queries
$packageitemid=SELECT min(packageitems.packageitemid) FROM packageitems LEFT JOIN products ON packageitems.productid = products.productid
 select productid from packageitems where packageitemid=$packageitemid

I want the productid where packageitemid is the min

0
Comment
Question by:rgb192
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 333 total points
ID: 34980874
Check whether this is working ?
SELECT top 1 productid, min(packageitemid) as minpackageitemid
FROM packageitems 
group by productid
order by minpackageitemid

Open in new window

0
 
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 333 total points
ID: 34980882
Also
select productid from packageitems where packageitemid=
(SELECT min(packageitems.packageitemid) FROM packageitems LEFT JOIN products ON packageitems.productid = products.productid)

Open in new window

0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 167 total points
ID: 34981619
Select productid
  from packageitems as pi
 Where packageitemid =
    (select min(packageitemid)
        from packageitems)
  order by 1

since its a left outer join products  you don't need to have it
0
 

Author Closing Comment

by:rgb192
ID: 34981916
thanks
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question