Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 T-SQL Question

Author  Topic 

RajeS
Starting Member

2 Posts

Posted - 2006-11-09 : 10:13:16
Hi,

I have two tables like Table A and Table B.
Table A has column like Pat_no, Prescrip.No,PrescriptionDate,Exp.Date
Table B has Column like Pat_no,Prescrip.No,RefillDate,Exp.date

My question is

If Table A and Table B has same Prescrip.No then I have to find Max(RefillDate) depends on Pat_no and prescrip.NO ( Prescrip.No may repeat in Table B)

And
If TableA has Prescrip.No and Table B does not have that Prescrip.No, I have find PrescriptionDate from Table A.

Could you please let me know, How can I do this.

Thanks
Raje

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-11-09 : 10:23:19
Is this homework?

STAR SCHEMAS ARE NOT DATA WAREHOUSES!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-09 : 11:51:18
use INNER JOIN and max().

Check out Books OnLine for the syntax.


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-09 : 19:59:48
Also Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -