[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Apply Commission based on Date Range

Posted on 2005-05-16
2
Medium Priority
?
217 Views
Last Modified: 2010-03-19
Hi,

I have 2 tables;

Table1: CALCULATIONS containing fields [Date], [time], Final_Destination, pstn
Table2: s_TrackRealCDR containing fields DateID, SDate, EDate, Commission

I want to make a VIEW where I want CACULATIONS table to display together with Commission column from s_TrackRealCDR table where Date is between EDate (start date) and  EDate (end date).

I hope I am able to explain what I need. Nevertheless I am available to give some examples.

Nick
0
Comment
Question by:NickHoward
2 Comments
 
LVL 23

Accepted Solution

by:
adathelad earned 1000 total points
ID: 14009257
Hi,

It sounds like this is what you need:

SELECT c.Date, c.Time, c.Final_Destination, c.pstn, (SELECT TOP 1 t.Commission FROM s_TrackRealCDR t WHERE c.Date BETWEEN t.SDate AND t.EDate ORDER BY t.SDate) AS Commission
FROM CALCULATIONS c

0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 14010107
SELECT CALCULATIONS.[Date],
     CALCULATIONS.[time],
     CALCULATIONS.Final_Destination,
     CALCULATIONS.pstn,
     s_TrackRealCDR.Commission
FROM CALCULATIONS
INNER JOIN s_TrackRealCDR
     ON CALCULATIONS.[Date] BETWEEN s_TrackRealCDR.SDate AND s_TrackRealCDR.EDate
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

834 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