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

Database

 
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 
My previous SQL would return too many rows. Try this instead.
select t.product
      ,t.last_date
      ,pod.local_expect_cost
  from ( select pod.product
               ,max(poh.date_entered) last_date
           from poheadm poh
               ,podetm pod
          where poh.order_no = pod.order_no
          group by pod.product ) t
       ,poheadm poh
       ,podetm pod
 where poh.date_entered = t.last_date
   and poh.order_no = pod.order_no
   and pod.product = t.product


As long as your order header records have unique date time stamps, you should only get one record for each product. But this assumes that on the podetm table that the order_no, product fields are a unique key. If they are not a unique key, it possible that a product would appear twice.

Good Luck.



Chris Meech
I am Canadian. [heard in a local bar]

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

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.