Home » SQL & PL/SQL » SQL & PL/SQL » Latest Record
Latest Record [message #233382] Wed, 25 April 2007 23:28 Go to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

Hi everybody,

Can anyone help me to write sql query?

I have three tables design_master, purchase_master, purchase_detail.

Design Master table has the following field :

Design_no
Design_code
Opening_stock
Opening_rate

Purchase_master :

Sr_no
Sr_date

Purchase_detail :

Sr_no
Design_code
Rate_usd

Now the problem is I want to find the latest rate purchase for all the design.

How to find this?

Waiting for ur immediate reply.

Thx in advance

Samit Gandhi

Re: Latest Record [message #233397 is a reply to message #233382] Thu, 26 April 2007 01:07 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Join the 2 purchase tables, order the result by date descending and take the first row.

Regards
Michel
Re: Latest Record [message #233412 is a reply to message #233397] Thu, 26 April 2007 01:33 Go to previous messageGo to next message
akkumar81
Messages: 144
Registered: February 2007
Location: india
Senior Member

Micheal,

Explain some brief coding to samit.

Cool
Re: Latest Record [message #233418 is a reply to message #233412] Thu, 26 April 2007 01:47 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I gave the plan, the rest is basic SQL coding, if he doesn't know how to code he either has:
- tell us what is his problem
- take a SQL course

Regards
Michel
Re: Latest Record [message #233483 is a reply to message #233418] Thu, 26 April 2007 05:49 Go to previous messageGo to next message
samit_gandhi
Messages: 226
Registered: July 2005
Location: Hong Kong
Senior Member

thx i got the solution

samit gandhi
Re: Latest Record [message #233488 is a reply to message #233483] Thu, 26 April 2007 06:28 Go to previous messageGo to next message
pavuluri
Messages: 247
Registered: January 2007
Senior Member
Could you send me code
thanks
srinivas
Re: Latest Record [message #233491 is a reply to message #233488] Thu, 26 April 2007 06:43 Go to previous messageGo to next message
akkumar81
Messages: 144
Registered: February 2007
Location: india
Senior Member



Samit,

Can u send that code.

Thanks.

Laughing
Re: Latest Record [message #233492 is a reply to message #233491] Thu, 26 April 2007 06:58 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Why don't you two just try to do this yourself?
Like Michel said, this is quite straightforward, and with the help from some other threads in this forum, you should be able to solve it.
Re: Latest Record [message #233601 is a reply to message #233382] Thu, 26 April 2007 15:47 Go to previous message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
try the following. Without having the actual tables, it is a guess.


select a.design_no,c.sr_date,b.rate_usd
from design_master a,purchase_detail b,purchase_master c
where b.sr_no = c.sr_no
and a.design_code = b.design_code
and c.sr_date = (select max(d.sr_date)
                 from purchase_master d
                 where d.sr_no = b.sr_no);
Previous Topic: Number of triggers in a table.
Next Topic: sql null
Goto Forum:
  


Current Time: Sat Dec 03 20:13:54 CST 2016

Total time taken to generate the page: 0.10581 seconds