Click here to Skip to main content
15,925,206 members
Home / Discussions / Database
   

Database

 
AnswerRe: Knowing Table structure in Sybase Pin
PIEBALDconsult17-Jul-07 7:54
mvePIEBALDconsult17-Jul-07 7:54 
Questionnewbie: How can I see the warnings when creating DB from file? Pin
Atara17-Jul-07 1:57
Atara17-Jul-07 1:57 
AnswerRe: newbie: How can I see the warnings when creating DB from file? Pin
Atara17-Jul-07 21:02
Atara17-Jul-07 21:02 
QuestionORA-12705: Cannot access NLS data files or invalid environment specified Pin
qtuan16-Jul-07 22:25
qtuan16-Jul-07 22:25 
QuestionProblem in Query Pin
Khan.Bangash16-Jul-07 21:42
Khan.Bangash16-Jul-07 21:42 
AnswerRe: Problem in Query Pin
andyharman16-Jul-07 22:17
professionalandyharman16-Jul-07 22:17 
GeneralRe: Problem in Query Pin
Khan.Bangash16-Jul-07 22:30
Khan.Bangash16-Jul-07 22:30 
AnswerRe: Problem in Query Pin
andyharman17-Jul-07 1:23
professionalandyharman17-Jul-07 1:23 
I'm not really sure what you are trying to acheive with the "cust_debit" table. It looks like it contains the amount outstanding for each order.

If it is the amount outstanding then the following change would give you the latest order for any customer who has a total of more than 2000 outstanding:
....
   from (
      select customer_id, max(order_id)
      from cust_order
      inner join cust_debit
        on cust_debit.order_id = cust_order.order_id
      group by customerId
      having sum(cust_debit.amount) >= 2000
   ) as lastest_order_id
....
The following uses a correlated-subquery to give you customers where any one single order has more than 2000 outstanding:
....
   from (
      select customer_id, max(order_id)
      from cust_order
      where 2000 <= (
         select sum(cust_debit.amount) from cust_debit
         where cust_debit.order_id = cust_order_id)
      group by customerId
   ) as lastest_order_id
....
Both examples give the details of the most-recent order. If you want the oldest order then use min(order_id). Hopefully you should now be able to solve your problem using one of these examples.

Regards
Andy
GeneralRe: Problem in Query Pin
Khan.Bangash17-Jul-07 1:55
Khan.Bangash17-Jul-07 1:55 
AnswerRe: Problem in Query Pin
andyharman17-Jul-07 3:18
professionalandyharman17-Jul-07 3:18 
QuestionRights needed to create tablespace in oracle? Pin
Mushtaque Nizamani16-Jul-07 20:25
Mushtaque Nizamani16-Jul-07 20:25 
AnswerRe: Rights needed to create tablespace in oracle? [modified] Pin
andyharman16-Jul-07 20:31
professionalandyharman16-Jul-07 20:31 
QuestionDoubt in query........., Pin
Member 387988116-Jul-07 19:12
Member 387988116-Jul-07 19:12 
AnswerRe: Doubt in query........., [modified] Pin
andyharman16-Jul-07 20:24
professionalandyharman16-Jul-07 20:24 
GeneralRe: Doubt in query........., Pin
Member 387988116-Jul-07 20:36
Member 387988116-Jul-07 20:36 
GeneralRe: Doubt in query........., Pin
andyharman16-Jul-07 21:17
professionalandyharman16-Jul-07 21:17 
GeneralRe: Doubt in query........., Pin
RepliCrux16-Jul-07 20:37
RepliCrux16-Jul-07 20:37 
GeneralRe: Doubt in query........., Pin
RepliCrux16-Jul-07 20:53
RepliCrux16-Jul-07 20:53 
GeneralRe: Doubt in query........., Pin
Member 387988116-Jul-07 21:01
Member 387988116-Jul-07 21:01 
GeneralRe: Doubt in query........., Pin
ChandraRam17-Jul-07 4:01
ChandraRam17-Jul-07 4:01 
GeneralRe: Doubt in query........., Pin
ChandraRam17-Jul-07 4:11
ChandraRam17-Jul-07 4:11 
AnswerRe: Doubt in query........., Pin
N a v a n e e t h16-Jul-07 20:37
N a v a n e e t h16-Jul-07 20:37 
GeneralRe: Doubt in query........., Pin
Member 387988116-Jul-07 20:57
Member 387988116-Jul-07 20:57 
AnswerRe: Doubt in query........., Pin
Krish - KP16-Jul-07 21:20
Krish - KP16-Jul-07 21:20 
GeneralRe: Doubt in query........., Pin
RepliCrux17-Jul-07 12:40
RepliCrux17-Jul-07 12:40 

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.