MySQL Forums
Forum List  »  Newbie

querydesign
Posted by: Maik Kerner
Date: August 04, 2005 07:52AM

I have a problem to design a query for mysql.

I have two tables like these one:

table1:

Number;ClientID;DateBeginn;DateEnd;Data
1;1;20050101;20050102;A
2;1;20050102;20050104;B
3;1;20050104;20050105;C

table2:

ClientID;Name;Surname;
1;Test;Test

I want to design three querrys:

The first one:
Give me for each client in table2 his name and surename and give me for this client the data in table2 which is the oldest one (from beginn)
Solution: 1;Test;Test;A

The second one:
Give me for each client in table2 his name and surename and give me for this client the data in table2 which is the newest one (from beginn)
Solution: 1;Test;Test;C

The third one:
Give me for each client in table2 his name and surename and give me for this client the data in table2 which difference (dateend - datebeginn) is the biggest.
Solution: 1;Test;Test;B

Can anybody help me to design these querys?

THX a lot

Options: ReplyQuote


Subject
Written By
Posted
querydesign
August 04, 2005 07:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.