Skip to content

Tag: sql

SQL Query for max value from subsets

I have a table bls_jobs with the following columns: city, state, occ_title, jobs_1000, and loc_quotient I am trying to retrieve the highest loc_quotient for each city (each city has several occ_titles, and each occ_title has a loc_quotient) Currently, I can use this query: Which does return what I’m loo…

Merge tables in R and update rows where dates overlap

I hope this makes sense – it’s my first post here so I’m sorry if the question is badly formed. I have tables OldData and NewData: I need merge these tables as below. Where IDs match, dates overlap, and Priority is higher in NewData, I need to update the dates in OldData to reflect NewData. …