Solved

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

Posted on 2015-01-08
2
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

628 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