Click here to Skip to main content
15,886,634 members
Home / Discussions / Database
   

Database

 
GeneralRe: I can not drop table after upgrading to sql 2008 r2 from sql 2005 Pin
Pete O'Hanlon23-Apr-12 1:13
mvePete O'Hanlon23-Apr-12 1:13 
QuestionSQL 2008 to SQL2005 Pin
jojoba201122-Apr-12 21:25
jojoba201122-Apr-12 21:25 
AnswerRe: SQL 2008 to SQL2005 Pin
Blue_Boy22-Apr-12 21:43
Blue_Boy22-Apr-12 21:43 
QuestionRe: SQL 2008 to SQL2005 Pin
jojoba201122-Apr-12 22:02
jojoba201122-Apr-12 22:02 
AnswerRe: SQL 2008 to SQL2005 Pin
Mycroft Holmes22-Apr-12 22:46
professionalMycroft Holmes22-Apr-12 22:46 
AnswerRe: SQL 2008 to SQL2005 Pin
Eddy Vluggen23-Apr-12 0:20
professionalEddy Vluggen23-Apr-12 0:20 
QuestionRe: SQL 2008 to SQL2005 Pin
jojoba201122-Apr-12 23:10
jojoba201122-Apr-12 23:10 
QuestionSQL Get Max for each group Pin
Richard.Berry10020-Apr-12 11:52
Richard.Berry10020-Apr-12 11:52 
Hi

I posted a similar question to this here [^]

however after looking at the data in more detail, the query has to be changed a lot. Also in the previous post, I could not get it to work.

The select statement below is what i need except, this returns all the rows for each product, and all I need is the MAX date_despatched for EACH product


SELECT scheme_opdetm.warehouse, scheme_opdetm.product, scheme_opdetm.net_price, scheme_opdetm.despatched_qty, scheme_opheadm.date_despatched
FROM scheme_opdetm INNER JOIN scheme_opheadm ON scheme_opdetm.order_no = scheme_opheadm.order_no
WHERE (((scheme_opheadm.status)="8") AND ((scheme_opdetm.warehouse)="06") AND ((scheme_opdetm.net_price)>0) AND ((scheme_opdetm.despatched_qty)>0))
ORDER BY scheme_opdetm.product, scheme_opheadm.date_despatched DESC;


Basically the Sales Order Header (scheme_opheadm) contains the Date Despatched, Sales Order, ans Status (which must be 8 for despatched orders).

The Sales Order Detail (scheme_opdetm) has the Warehouse Product Net Price (There are also comments and other lines that I need to ignore in the Detail Table, hence the filters for Net Price > 0, Qty Despatched > 0, Warehouse = 06 (finished goods).

How can I get only the details of the LAST despatch for EACH item?
AnswerRe: SQL Get Max for each group Pin
Mycroft Holmes20-Apr-12 13:40
professionalMycroft Holmes20-Apr-12 13:40 
GeneralRe: SQL Get Max for each group Pin
Richard.Berry10020-Apr-12 20:51
Richard.Berry10020-Apr-12 20:51 
GeneralRe: SQL Get Max for each group Pin
Mycroft Holmes20-Apr-12 21:23
professionalMycroft Holmes20-Apr-12 21:23 
AnswerRe: SQL Get Max for each group Pin
Jörgen Andersson21-Apr-12 1:18
professionalJörgen Andersson21-Apr-12 1:18 
GeneralRe: SQL Get Max for each group Pin
Richard.Berry10021-Apr-12 2:41
Richard.Berry10021-Apr-12 2:41 
GeneralRe: SQL Get Max for each group Pin
Jörgen Andersson21-Apr-12 6:44
professionalJörgen Andersson21-Apr-12 6:44 
GeneralRe: SQL Get Max for each group Pin
vvashishta23-Apr-12 19:16
vvashishta23-Apr-12 19:16 
QuestionSSRS 2005 question Pin
SQL Ed20-Apr-12 10:13
SQL Ed20-Apr-12 10:13 
Questionmysql to ms sql server Pin
Ramkumar_S19-Apr-12 21:27
Ramkumar_S19-Apr-12 21:27 
AnswerRe: mysql to ms sql server Pin
Eddy Vluggen20-Apr-12 0:48
professionalEddy Vluggen20-Apr-12 0:48 
AnswerRe: mysql to ms sql server Pin
jschell20-Apr-12 10:27
jschell20-Apr-12 10:27 
QuestionGetting unique combination of rows in SQL?? Pin
Lima318-Apr-12 21:08
Lima318-Apr-12 21:08 
AnswerRe: Getting unique combination of rows in SQL?? Pin
AHSAN11118-Apr-12 21:31
professionalAHSAN11118-Apr-12 21:31 
AnswerRe: Getting unique combination of rows in SQL?? Pin
Blue_Boy19-Apr-12 0:57
Blue_Boy19-Apr-12 0:57 
GeneralRe: Getting unique combination of rows in SQL?? Pin
Lima319-Apr-12 1:53
Lima319-Apr-12 1:53 
GeneralRe: Getting unique combination of rows in SQL?? Pin
Lima319-Apr-12 1:56
Lima319-Apr-12 1:56 
GeneralRe: Getting unique combination of rows in SQL?? Pin
Lima319-Apr-12 2:38
Lima319-Apr-12 2:38 

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.