Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.70 KB | None | 0 0
  1. select
  2.     user_pub_id
  3. from
  4.     identity_custom_fields_values as icfv
  5.     inner join identity_custom_fields_defenitions as icfd on icfd.pub_id = icfv.defenition_pub_id
  6.     inner join identity_host as ih on ih.aid = icfd.aid
  7. where
  8.     icfd.aid = "aid" and
  9.     (icfv.pub_id = 'fieldId1' and icfv.value = 'value1') or
  10.     (icfv.pub_id = 'fieldId2' and icfv.value like 'value2') or
  11.     (icfv.pub_id = 'fieldId3' and icfv.value between cast('2016-01-29' as DATE) and cast('2017-01-29' as DATE)) or
  12.     (icfv.pub_id = 'fieldId4' and icfv.value in ('value3','value4')) or
  13.     (icfv.pub_id = 'fieldId5' and icfv.value between 100 and 200 )
  14. group by
  15.     user_pub_id
  16. having
  17.     count(distinct icfv.pub_id) = 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement