Update query for bug 1225664

Update query based on discussion in bug. Remove bug 1242777 as its a
duplicate of 1225664

Change-Id: I8133d8d740ff407499afde7dfea0d3d2171ee34d