Report from multiple tables.

  • 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

  • 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

  • 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.

    39003900N FULTON AVE

    600600RESERVE BLVD

    700700RESERVE BLVD

    400499APPLEWOOD CT

    44004699APPLEWOOD 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.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply