pandugadu999 Posted November 21, 2014 Report Posted November 21, 2014 i have two tables... table A table B -------- ----------------- MonthYear Value StartDate EndDate ---------------- ----------------------------------------------------------- Jan 2014 90 2014-01-01 2014-04-31 Feb 2014 100 2014-05-01 Null Mar 2014 Apr 2014 May 2014 Jun 2014 ee two tables ni join chesi, result lo ila ravvali,,,, beased on StartDate and EndDate columns, assign correct value to MonthYear, ex: Jan 2014 is between 2014-01-01 2014-04-31 so 90 value assigned....like that. MonthYear Value ---------------- ------------ Jan 2014 90 Feb 2014 90 Mar 2014 90 Apr 2014 90 May 2014 100 Jun 2014 100 experts ...help plz
JollyBoy Posted November 21, 2014 Report Posted November 21, 2014 ex: Jan 2014 is between 2014-01-01 2014-04-31 so 90 value assigned....like that. cheppav kada anthe
pandugadu999 Posted November 21, 2014 Author Report Posted November 21, 2014 ex: Jan 2014 is between 2014-01-01 2014-04-31 so 90 value assigned....like that. cheppav kada anthe query ela rayalo seppu ba.....
funny_guy Posted November 21, 2014 Report Posted November 21, 2014 nenu sql lo antha expert ni kannu but I can give you a suggestion two tables ni join cheyadaaniki common columns levu..based on your explanation..I would say create a function or SP 1) Create a function/SP that returns table 2) Create a temp table with monthYear and Values in the fucntion 3) Loop the temp table and assign Values based on Start Date and End Date Now your function returns a table with expected data You can use select statement to call the function or Exec sp Hope this will help you... inka evarina bettr idea isthe follow them..
Popkatapetapotapulti Posted November 21, 2014 Report Posted November 21, 2014 i m unable to post query
MegaPowerRockstar Posted November 21, 2014 Report Posted November 21, 2014 what is the common column for both tables Select ta.MonthYear, (select tb.Value from tableB tb where tb.startDate >= ta.MonthYear And tb.EndDate <= ta.MonthYear ) As Value from tableA ta Something like this should help you.... you might need to add date conversions... I need to leave....so give it a try
vikuba Posted November 21, 2014 Report Posted November 21, 2014 is there a common column to join both the tables?
pandugadu999 Posted November 21, 2014 Author Report Posted November 21, 2014 is there a common column to join both the tables? no common column...we have to use those startdate and enddate to link with MonthYear
Recommended Posts