Skip to content

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

Indexing (x 4 OR y 5)

I am searching for an index to make the following quick: The query is a delete and reads: so it deletes all rows that do not match a few hundred criteria on t1 and t2. explain gives a sequential scan and rearranges the query: Can I create an index that will avoid that full scan? Thanks in advance! Answer Alth…