Skip to content

Instantly share code, notes, and snippets.

@phil
Created September 23, 2013 11:56
Show Gist options
  • Select an option

  • Save phil/6669508 to your computer and use it in GitHub Desktop.

Select an option

Save phil/6669508 to your computer and use it in GitHub Desktop.
App Aperture SQL: Count Photos by make, model, lens
select count(results.versionid) as c, results.* from
(select t.versionid, max(t_make.stringproperty) as make_string, max(t_model.stringproperty) as model_string, max(t_lens.stringproperty) as lens_string from rkexifstringproperty t
left outer join (select stringProperty, modelid from rkuniquestring) t_model on (t_model.modelid = t.stringid and t.propertykey = 'Model')
left outer join (select stringProperty, modelid from rkuniquestring) t_make on t_make.modelid = t.stringid and t.propertykey = 'Make'
left outer join (select stringProperty, modelid from rkuniquestring) t_lens on t_lens.modelid = t.stringid and t.propertykey = 'LensModel'
/*where propertykey = 'Model' /* use any of 'LensModel', 'Model' */
group by t.versionid) results
group by results.lens_string, results.model_string
order by results.model_string, results.lens_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment