William Gary Wright (5/13/2013)
I work at a 911 center. Our data is sensitive and proprietary. I also have a contract with our software vendor to not disclose any information about their software. With that in mind this is why I posted the way I did, most of the names I used are not even used in the actual database. I tried to explain what I need without getting into to much detail about the data and I thougt what I sent might be enouigh.
I will try again.
I certainly understand sensitive data. Many of us around here work with sensitive data as a normal part of our day. For these types of things you just need obfuscate the data but keep it representative of the issue. Certainly nothing wrong with changing column names and only including columns relevant to the issue at hand. That makes it an example of how to do whatever it is you are doing and does reveal any real actual information.
I was pretty sure that all you needed was to join those two tables until I ran into this:
The values for the where clause will come form this query and I need to loop these values through the first query.
I have no idea what that means.
I was thinking initially that you wanted something like you were trying to use streetranges columns as some way to validate what is there.
Completely blind due to no information but here are a couple of shots in the dark.
from streets s
join streetranges sr on sr.streetnumber = s.streetnumber
join streetranges sr2 on sr.streetname = s.streetname
from streets s
calltime >= 'Sometime'
street in (select streetname from streetranges)
streetnumber >= (select min(streetfrom) from streetranges)
streetnumber <= (select min(streetto) from streetranges)
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's splitter
.Cross Tabs and Pivots, Part 1 – Converting Rows to Columns Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs Understanding and Using APPLY (Part 1)Understanding and Using APPLY (Part 2)