Solved

Query

Posted on 2002-05-11
7
144 Views
Last Modified: 2010-04-04
Hello

My DataBase is Paradox.

And I have 3 tables

table 1:

ID    BeignDate   Price
1      1-1-2001      1.21
1      1-2-2001      5.21
1      2-2-2002     10.22
2      5-5-2002     22.22
3      2-2-2002      1.11

table 2:
ID    BeginDate   Correction
1     1-3-2001      -.50
1     1-4-2001      +.10
2     1-1-2002      -.02
5     6-6-2002     10.01

Table 3
ID   Name
1    A
2    B
3    C
4    D
5    E

I want to select The LAST Price for each ID
Price := Price + Correction

The Result Table:

ID Last Price
1       10.32
2       22.20
3        1.11
5       10.01

Can anybody help me with SQL Statement?

Thanks.
0
Comment
Question by:pmarkov
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:nestorua
ID: 7003097
HI,
Try this:
SELECT A.ID, A.PRICE+B.CORRECTION AS LASTPRICE  
FROM TABLE1 A
JOIN TABLE2 B ON B.ID=A.ID
WHERE (A.BEGINDATE=
        (SELECT MAX(BEGINDATE) FROM TABLE1
         WHERE ID=A.ID))
AND
        (B.BEGINDATE=
        (SELECT MAX(BEGINDATE) FROM TABLE2
         WHERE ID=B.ID))

If everything will be good - fine, if not - inform me.
Sincerely,
Nestorua.
0
 
LVL 4

Expert Comment

by:nestorua
ID: 7003129
I suppose the Fields are not NULL although.
Sincerely,
Nestorua.
0
 

Author Comment

by:pmarkov
ID: 7005263
Thanks! :)))

This is good but there is one problem.

Look at row 4 in Result table where ID = 5!
ID = 5 exist in table 2 but NOT exist in table 1 :)

Thaks againg.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:pmarkov
ID: 7005265
... and what about  Table 3? Can you put the NAME of ID in the result table?
0
 
LVL 4

Accepted Solution

by:
nestorua earned 100 total points
ID: 7006471
HI,
From your example Table3 doesn't effect onthe result.

Sincerely,
Nestorua.
0
 

Author Comment

by:pmarkov
ID: 7007741
This is good but there is one problem.

Look at row 4 in Result table where ID = 5!
ID = 5 exist in table 2 but NOT exist in table 1 :)

Thaks againg.
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9005623
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from nestorua

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now