nate123
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by nate123
-
-
I have a conundrum i'm trying to figure out and hoping for some help. In my simplified example below, I am looking for a query that will distinctly count the number of IDs in column 1 based on the criteria that City = Chicago and Existing Customer = Yes. The problem is that there are some IDs that meet both criteria, but not on the same record.
I can write a query that gives me a count of 1 (the ID that has both criteria on the same record), but I need a query that will give me a count of 2. Is this possible in SQL? Any guidance is appreciated. Thanks!
ID City Existing Customer 123456 Chicago 123456 Yes 789012 Chicago Yes
SQL query to count unique IDs that meet criteria in 2 columns where criteria are not always present on same row
in SQL
Posted
Thanks for the input. I agree it's not an optimal way to store data. My example may not have been great. The actual dataset is timestamped event data (think transaction logs), so it's not uncommon for some events for a given customer to have certain columns be null, and present on other events. I'm thinking this just might not be feasible with the dataset I have (which has lots of columns).