Solved

I want the productid where packageitemid is the min

Posted on 2011-02-25
4
227 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now