Solved

I want the productid where packageitemid is the min

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

911 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

23 Experts available now in Live!

Get 1:1 Help Now