我试过这段代码:
SELECT SUM(bookingstatus)
FROM beo_eventorder AS TotalBookingStatu
WHERE bookingstatus = 'Tentative';
但是这会返回0.表中有6个匹配项。 为什么这不会返回6?
列的屏幕截图:
答案 0 :(得分:1)
您应该使用class RpcClient(object):
def __init__(self):
parameters = pika.URLParameters('amqp://djeo4uf8:f4323HekqiVXgt_vlnqPfJnvJruzszbn@sad-groundsel-39.bigwig.lshift.net:10722/fl1sX7CbcDds')
parameters.socket_timeout = 5
self.connection = pika.BlockingConnection(parameters)
self.channel = self.connection.channel()
result = self.channel.queue_declare(exclusive=True)
self.callback_queue = result.method.queue
self.channel.basic_consume(self.on_response, no_ack=True,
queue=self.callback_queue)
def on_response(self, ch, method, props, body):
if self.corr_id == props.correlation_id:
self.response =loads( b64decode(body) )
def call(self, dict_data):
self.response = None
self.corr_id = str(uuid.uuid4())
self.channel.basic_publish(exchange='',
routing_key='rpc_queue',
properties=pika.BasicProperties(
reply_to = self.callback_queue,
correlation_id = self.corr_id,
),
body=b64encode( dumps(dict_data) ) )
while self.response is None:
self.connection.process_data_events()
self.channel.close()
self.connection.close()
return self.response
代替rpc = RpcClient()
response = rpc.call(payloadObj)
:
count
答案 1 :(得分:0)
SUM
添加了列上的所有元素,在您的情况下,它将所有字符串添加为0.您应该使用COUNT
函数。