elsenorjose
Technical User
...where several columns have to meet a certain criteria?
I need to find URLs, count how many of them there are, and sum how many bytes were delivered where:
a) The URL has a certain string in it anywhere;
b) Certain other fields in the table are NULL or have missing data or a specific value:
The source data isn't very clean and I get NULLs, spaces, or hyphens to indicate missing values in those fields. (Yes, I know and the engineers ARE working on cleaning that up). But right now this is what I have to work with.
This thing is taking HOURS to run. Any suggestions?
I need to find URLs, count how many of them there are, and sum how many bytes were delivered where:
a) The URL has a certain string in it anywhere;
b) Certain other fields in the table are NULL or have missing data or a specific value:
Code:
select url, count(url), sum(bytes)
from url_table
where url like '%somestring%'
and
((market is null or market = ' ' or market = '-')
or (station is null or station = ' ' or station ='-')
or (artist is null or artist = ' ' or artist = '-')
or (track is null or track = ' ' or track = '-')
or (label is null or label = ' ' or label - '-'))
group by url
The source data isn't very clean and I get NULLs, spaces, or hyphens to indicate missing values in those fields. (Yes, I know and the engineers ARE working on cleaning that up). But right now this is what I have to work with.
This thing is taking HOURS to run. Any suggestions?