Solved

I want the productid where packageitemid is the min

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

792 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