July 31, 2008 at 6:10 am
hi,
I want to add records in my detail part from two different datasets.How to do yhat?
thanks
Abaso
July 31, 2008 at 10:30 am
Abaso,
Assuming there is no way to combine the data into one query the only way I am aware of doing this is by creating a sub-report. What exactly is it that you are trying to do?
Steve
July 31, 2008 at 11:51 pm
Steve,
Actually i want to display prv months and current months records depend upon selection of date.So that i am using two different queries but it shoes records only from dataset which has assigned to table.
August 1, 2008 at 6:10 am
Abaso,
You should be able to do this within one dataset. You do this within the query by creating two sub tables, either within one query or you can just create the two tables as temp tables, and the final selection has both previous and current month data. Then it should not be too difficult to display the data on the report.
Let me know if you need more explanation on how to do this or if I am not getting what you are trying to do.
Steve
August 1, 2008 at 6:31 am
Thank u Steve,
Exact u got my problem.But will u tell me how to use temp tables?
August 1, 2008 at 7:14 am
Here are two basic ideas, keep in mind that I don't know the data and the tables, so things may need to be slightly different for you but the basics should be the same.
Inner tables:
SELECT prev_Month, curr_Month, prev_Data, curr_Data
FROM (SELECT prev_id, prev_Month, prev_Data
FROM tbl
WHERE Month = previous_month) prev
(SELECT curr_id, curr_Month, curr_Data
FROM tbl
WHERE Month = current_month) curr
WHERE prev_id = curr_id
Or you can also do a JOIN on the two tables.
Temp tables:
SELECT prev_id, prev_Month, prev_Data
INTO #prev_Month
FROM tbl
WHERE Month = previous_month
SELECT curr_id, curr_Month, curr_Data
INTO #curr_Month
FROM tbl
WHERE Month = curr_month
SELECT prev_Month, curr_Month, prev_Data, curr_Data
FROM #prev_Month prev
INNER JOIN curr_month curr ON prev_id = curr_id
The one consideration you need to keep in mind here is dropping the temp tables. Technically they should be dropped when the connection goes away but I am not totally convinced that happens. I usually drop the tables at the end of the script to be sure.
Let me know if you need clarifications on what I am saying here.
August 1, 2008 at 7:50 am
thank u very much Steve,It's Working.
August 2, 2008 at 6:08 am
Steve I m giving 2 tables in brief
tbl1 contains date,Monthkey,prvmonthkey where monthky becomes prvmonthkey in next month.
tbl2 contains acs,amt.
so i have write nested query n its not working properly.
August 5, 2008 at 6:15 am
Hi Abaso,
Sorry for the delay I had a long weekend off. Can you post your query so that I can see what you are trying to do?
August 6, 2008 at 8:20 am
Hi Steve,
I solved my problem,i found very useful sql which u send
thank u
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply