Solved

Merge fields from two tables in a view based on a span of days

Posted on 2015-01-08
2
49 Views
Last Modified: 2015-01-08
I have two tables;  PayData  with 5 fields:  PRDate, Dept, Amount, Hours, EarnCode and PaySched with 5 fields; PRNum, FromDate, ThroughDate, RptDate, Year.  


I want to merge the field values within the PayData file with the correct PRNum when the PayData.PRDate falls within the PaySched.FromDate and PaySched.ThroughDate.


How can I define the view to get what I need?

Thanks

Glen
0
Comment
Question by:GPSPOW
2 Comments
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 500 total points
ID: 40539123
--CREATE VIEW [view_name] AS
SELECT pd.*, ps.* --whatever columns you need from each table
FROM PayData pd
LEFT OUTER JOIN PaySched ps ON
    pd.PRDate >= ps.FromDate AND
    pd.PRDate <= ps.ThroughDate
0
 

Author Closing Comment

by:GPSPOW
ID: 40539178
Thank you
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

705 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

21 Experts available now in Live!

Get 1:1 Help Now