Click here to Skip to main content
15,901,205 members
Home / Discussions / Database
   

Database

 
QuestionGetting Last Day of Month: Pin
Shahzad.Aslam28-Aug-07 1:30
Shahzad.Aslam28-Aug-07 1:30 
AnswerRe: Getting Last Day of Month: Pin
mihirhp28-Aug-07 1:53
mihirhp28-Aug-07 1:53 
GeneralRe: Getting Last Day of Month: Pin
Shahzad.Aslam28-Aug-07 3:34
Shahzad.Aslam28-Aug-07 3:34 
QuestionRadioButtons are not working Pin
RaveRare27-Aug-07 18:46
RaveRare27-Aug-07 18:46 
AnswerRe: RadioButtons are not working Pin
Widgets30-Aug-07 22:43
Widgets30-Aug-07 22:43 
Questionsqlserver and msoffice Pin
kalyan_241627-Aug-07 18:13
kalyan_241627-Aug-07 18:13 
QuestionUsing SqlFacet Attributes for an SQL function Pin
~~~Johnny~~~27-Aug-07 11:17
~~~Johnny~~~27-Aug-07 11:17 
QuestionSELECT MAX Pin
RichardBerry27-Aug-07 6:16
RichardBerry27-Aug-07 6:16 
Hi
Using MS Query for Excel connecting to a SQL Server 2000 database through ODBC.

I am trying to get the last purchase Order price for all products

There are two tables containing the info I need:

Table: poheadm (Purchase Order Header)
order_no
date_entered

Table: podetm (Purchase Order Detail)
order_no
product
local_expect_cost (i.e. the price)

The following statement gives an error "Could not add the table "(SELECT."

SELECT podetm.product, podetm.cost
FROM podetm podetm,
(SELECT max(poheadm.date_entered) as maxdate, poheadm.order_no
FROM poheadm poheadm
GROUP BY order_no) maxresults
WHERE podetm.order_no = maxresults.order_no

The following statement runs, but I get multiple results for each product, not just the latest price

SELECT podetm.product, podetm.local_expect_cost,
(SELECT max(poheadm.date_entered)
FROM poheadm poheadm
WHERE poheadm.order_no = podetm.order_no)
FROM podetm podetm
QuestionRe: SELECT MAX Pin
Kschuler27-Aug-07 9:59
Kschuler27-Aug-07 9:59 
AnswerRe: SELECT MAX Pin
RichardBerry27-Aug-07 21:55
RichardBerry27-Aug-07 21:55 
GeneralRe: SELECT MAX Pin
Kschuler30-Aug-07 4:24
Kschuler30-Aug-07 4:24 
GeneralRe: SELECT MAX [modified] Pin
RichardBerry30-Aug-07 4:53
RichardBerry30-Aug-07 4:53 
AnswerRe: SELECT MAX Pin
Chris Meech27-Aug-07 10:45
Chris Meech27-Aug-07 10:45 
GeneralRe: SELECT MAX Pin
RichardBerry27-Aug-07 22:00
RichardBerry27-Aug-07 22:00 
GeneralRe: SELECT MAX Pin
RichardBerry27-Aug-07 22:12
RichardBerry27-Aug-07 22:12 
GeneralRe: SELECT MAX Pin
Chris Meech28-Aug-07 7:35
Chris Meech28-Aug-07 7:35 
GeneralRe: SELECT MAX Pin
RichardBerry29-Aug-07 1:43
RichardBerry29-Aug-07 1:43 
Question"Set Default" doesn't work [modified] Pin
Meysam Mahfouzi27-Aug-07 4:01
Meysam Mahfouzi27-Aug-07 4:01 
AnswerRe: "Set Default" doesn't work Pin
Meysam Mahfouzi27-Aug-07 5:23
Meysam Mahfouzi27-Aug-07 5:23 
Questionlarge scale inserts duplicate checking Pin
brsecu27-Aug-07 3:34
brsecu27-Aug-07 3:34 
AnswerRe: large scale inserts duplicate checking Pin
Michael Potter27-Aug-07 5:17
Michael Potter27-Aug-07 5:17 
QuestionSetting up POS [modified] Pin
dptalt27-Aug-07 3:21
dptalt27-Aug-07 3:21 
QuestionSQL Vs Oracle Pin
Ahamed Azeem27-Aug-07 2:43
Ahamed Azeem27-Aug-07 2:43 
AnswerRe: SQL Vs Oracle Pin
andyharman27-Aug-07 22:49
professionalandyharman27-Aug-07 22:49 
QuestionSQL Replication Compatibility Pin
MatthysDT27-Aug-07 1:51
MatthysDT27-Aug-07 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.