from operator import itemgetter
# if you would like to play with multiple dictionaries then here you go:
# Three dictionaries that are composed of first name and last name.
user = [
{'fname': 'Mo', 'lname': 'Mahjoub'},
{'fname': 'Abdo', 'lname': 'Al-hebashi'},
{'fname': 'Ali', 'lname': 'Muhammad'}
]
# This loop will sort by the first and the last names.
# notice that in a dictionary order doesn't matter. So it could put the first name first or the last name first.
for k in sorted (user, key=itemgetter ('fname', 'lname')):
print (k)
# This one will sort by the first name only.
for x in sorted (user, key=itemgetter ('fname')):
print (x)
Я думаю, вам нужны скобки в вашем предложении where ...
WHERE
chartTime >= CONVERT(datetime, '2013-06-01 00:00:00')
AND
(interventionId IN (SELECT [interventionId]
FROM [CISReportingDB].[dbo].[PtAssessment]
WHERE interventionId IN (6659, 9899, 11870))
OR verboseForm LIKE 'sibil. exp%'
OR attributeId LIKE '67194%')
Это вернет строки, где chartTime >= '2013-06-01 00:00:00'
ваша дата ... и одно из других условий завершается. Без круглых скобок у вас есть противоречивая логика AND / OR, означающая, что она вернет строки, где verboseForm LIKE 'sibil. exp%' OR attributeId LIKE '67194%'
В противном случае вам нужно убедиться, что есть строки, которые действительно соответствуют вашей фильтрации ... что означает interventionId
либо 6659,9899, либо 11870, либо verboseForm LIKE 'sibil. exp%' OR attributeId LIKE '67194%'
.
Наконец, предложение IN является избыточным ... вы можете просто перечислить значения один раз:
WHERE
chartTime >= CONVERT(datetime, '2013-06-01 00:00:00')
AND
(interventionId IN (6659, 9899, 11870)
OR verboseForm LIKE 'sibil. exp%'
OR attributeId LIKE '67194%')