SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Report from multiple tables.


Report from multiple tables.

Author
Message
William Gary Wright
William Gary Wright
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 112
I need to create a report. I have data in one table that represents street ranges. Example.
from to street category
100 200 Adams CFMH
300 400 Smith CFHM

There are numeroous ranges in the table above but I need to use the category code CFMH

I then have a second table that has historical information that referenced these ranges.
Example
streetno street
123 Adams
245 Adams
333 Smith

I need to pull the historical data based on the ranges.

Thanks,
Bill
sql1411
sql1411
SSC Veteran
SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)SSC Veteran (244 reputation)

Group: General Forum Members
Points: 244 Visits: 96
Your post is not clear in terms of the column names and what exactly are you looking at. Do you need a parameter in this report?

You should just be able to write a simple query for this as a dataset, joining both the tables based on the common column from both the table.

From example: You probably need two different datasets
Main dataset for report
SELECT A.*

FROM HistoricalTable as A
, RangeTable as B

WHERE A.CommonColumn = B.CommonColumn
AND B.StreetCategory LIKE '%CFHM'
AND B.StreetCategory = @StreetRanges;

Secondary dataset for parameter StreetRanges

Select DISTINCT StreetCategory

FROM RangeTable;


Now once you create your report, CLICK on the parameter @StreetRanges, SELECT "AvailableValues" -> then "Get values from a query". Choose the second dataset and the field that you've created to get the list of all the distinct ranges.

Hope this helps
William Gary Wright
William Gary Wright
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 112
Well I apologize as I am not very good at explaining this. We have a computer aided dispatch system with a sql database that stores information about 911 calls. Such as address, caller, time the call time came in, time units dispatched, arrived and so on.
We have quite a lot of apartment buildings and we are trying find a way to run reports on those apartments. In the table where call information is stored there is a street number field and a street name field. There is also another table that stores information about street ranges. There is from street#, a to street# and the street name. There is also a category field. What we planned on doing is getting the from street, to street and street name from this table based on a certain category. Then using this information get the information from the other table from the street# and street name columns.
I have tried subqueries and derived columns to get the data and I don't think a join will work in this case.

Here is kind of what I think I need to do.
Query:select rangefr, rangeto, street from premrang where category = 'CFMH'
Results.
3900 3900 N FULTON AVE
600 600 RESERVE BLVD
700 700 RESERVE BLVD
400 499 APPLEWOOD CT
4400 4699 APPLEWOOD CT

Take that information and loop it through this query.

select * from inmain
where calltime > '2013-01-01'
and streetno > 400
and streetno < 499
and streetonly = 'APPLEWOOD CT'

I am think I should be able to get the data I want but I have not put it together yet.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search