Click here to Skip to main content
15,918,742 members
Home / Discussions / Database
   

Database

 
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 
Hi Chris

That did not work either, I got multiple results for each product.

One entry in the PoHeadm table can have many line Items in Podetm table
The same product can appear many times in the podetm table, but each with a different order_no, and hence a different date_entered in the header table.

I tried to write a statement in English stating what I want, hoping that I could develop that into an SQL statement, but even that proved difficult.

Select each item from podetm, and return the product and cost of the order number that has the latest date_entered in the poheadm table????

Maybe if you have time to spend, you could try to write a statement based on the data below?

Header Table: Poheadm
Fields: |date_entered |order_no|
Data: |2007-05-28 |00001 |
Data: |2007-05-29 |00002 |

Detail Table: podetm
Fields: |order_no |local_expec_cost |product|
Data: |00001 | USD5.06 |AA01 |
Data: |00001 | USD1.00 |AA02 |
Data: |00001 | USD9.00 |AA03 |
Data: |00002 | USD7.00 |AA01 |
Data: |00002 | USD2.00 |AA04 |

So above we have TWO Purchase orders. Order 00001, has 3 line items. Order two has 2 line items.

As you can see, product AA01 is on TWO purchase orders, I want to create a list of EACH of the products in podetm, and I want the LAST price paid based on the date_entered field in the poheadm table. So for the above, the data I want returned would look as follows (each product is ONLY ONCE, and has the latest price and date):

|product |local_expect_cost |date_enetered|
|AA01 |USD7.00 |2007-05-29 | (Data from Latest Date Order2)
|AA02 |USD1.00 |2007-05-28 | (Only Ordered once)
|AA03 |USD9.00 |2007-05-29 |
|AA04 |USD2.00 |2007-05-29 |
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 
AnswerRe: SQL Replication Compatibility Pin
MatthysDT27-Aug-07 4:07
MatthysDT27-Aug-07 4:07 
QuestionHow to change datatype of DataColumn Pin
Nouman Bhatti27-Aug-07 1:35
Nouman Bhatti27-Aug-07 1:35 
AnswerRe: How to change datatype of DataColumn Pin
Blue_Boy27-Aug-07 1:42
Blue_Boy27-Aug-07 1:42 
QuestionLEFT JOIN ??? Pin
Halawlaws26-Aug-07 22:44
Halawlaws26-Aug-07 22:44 
AnswerRe: LEFT JOIN ??? Pin
Colin Angus Mackay27-Aug-07 0:55
Colin Angus Mackay27-Aug-07 0:55 
GeneralRe: LEFT JOIN ??? Pin
Halawlaws27-Aug-07 1:41
Halawlaws27-Aug-07 1:41 
GeneralRe: LEFT JOIN ??? Pin
Colin Angus Mackay27-Aug-07 2:27
Colin Angus Mackay27-Aug-07 2:27 
GeneralRe: LEFT JOIN ??? Pin
Halawlaws27-Aug-07 4:05
Halawlaws27-Aug-07 4:05 
AnswerRe: LEFT JOIN ??? Pin
Michael Potter27-Aug-07 5:31
Michael Potter27-Aug-07 5:31 

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.