Sql Query ...

Dear all,

I have one table which is EquipmentCostVersion which contains the period wise cost for equipment. You can see the table structure here.

6014.1.jpg

My requirement is , Lets assume that equipment WT0110 is assigned for one agreement which start from 02/01/2011 to 10/30/2012.

2350.2.jpg

When im segregate the data by giving equipId, FromDate and ToDate the value should be stored in WorkActivity Table as per the Period Wise from EquipmentCostVersion table… The Result should be shown like as below …

2867.3.jpg

Please share your Logic how to do by simple SQL Statement

Not clear about you requirement, as your resulted table shows a record for which the fromDate is 01/01/2011 where as your entry from date is 02/01/2011. Here is example query to find the records between the selected dates

while select EquipmentCostVersion

where EquipmentCostVersion.EquipId == selectedEquipId &&

(EquipmentCostVersion.FromDate >= selectedFromDate &&

EquipmentCostVersion.ToDate <= selectedToDate)

{

//////do the insert here

}