我想查询哪个输出已完成人工的所有job_ID(JobDone)
我尝试在查询中使用内连接,但未能完成我所寻求的内容。
SELECT * FROM `jobs` WHERE Status='JobDone' GROUP BY Job_id
以上查询还返回仅完成一项工作的值。
答案 0 :(得分:0)
使用join query
select j1.Name,j2.Labor from jobcard j1 innerjoin jobs j2 on j1.job_ID=j2.job_ID where j2.Status='JobDone' GROUP BY j2.job_ID
答案 1 :(得分:0)
我认为这是您的疑问:
SELECT j1.*, c.*
FROM jobs j1
INNER JOIN
(
SELECT Job_ID
FROM jobs
GROUP BY Job_ID
HAVING SUM(CASE WHEN Status <> 'JobDone' THEN 1 ELSE 0 END) = 0
) j2
ON j1.Job_ID = j2.Job_ID
INNER JOIN Jobcard c
ON t1.Job_ID = c.Job_ID
子查询聚合Job_id
并断言每个状态都已完成。此子查询生成一组ID,然后用于确定从表中选择的完整记录。
我还在Jobcard
表中添加了一个联接,但如果您愿意,可以随意将其删除。
答案 2 :(得分:0)
试试这个
SELECT Job_ID FROM Jobs WHERE Status LIKE 'JobDone'
答案 3 :(得分:0)
SELECT a.Job_id,a.Labor,c.Name
FROM `jobs` a
left join Jobcard c on a.Job_id=c.Job_id
WHERE not exists (select b.Job_id
FROM jobs b
WHERE Status<>'JobDone' AND b.Job_id=a.Job_id)
答案 4 :(得分:0)
如果您还希望使用Jobcard表中的名称,请使用以下查询:
SELECT ht.*
INTO @CurrentOverviewTableName
FROM @HistoryTableName ht
WHERE ht.LastUpdateDate = (SELECT MAX(h2.LastUpdateDate)
FROM @CurrentOverviewTableName ht2
WHERE ht2.id = ht.id
);
如果您不想获取名称,则无需加入表格,请使用以下查询:
{
"message": "Missing Authentication Token"
}
答案 5 :(得分:0)
你应该通过:Join with sql
无论如何,这是你的答案..
def main():
average = []
y_values = []
for x in range(0, 2501, 500):
for i in range(250):
average.append(calculate(x))
average = sum(average)
print("{} euro, {} worpen".format(i, average//250))
y_values.append(average//250)
x_values = [0, 500, 1000, 1500, 2000, 2500]
y_values = []
plt.plot(x_values, y_values)
plt.xlabel("Startgeld")
plt.ylabel("Aantal worpen")
plt.title("Monopoly")
plt.show()
def calculate(game_money):
piece = monopoly.Piece()
board = monopoly.Board()
owns = possession(board)
dice = throw()
throw_count = 0
number = 0
total_throw = 0
while not all(owns.values()):
number == throw()
piece.move(number)
total_throw = total_throw + number
throw_count += 1
if total_throw > 40:
game_money += 200
elif board.values[piece.location] > 0:
if game_money > board.values[piece.location]:
if owns[board.names[piece.location]] == False:
owns[board.names[piece.location]] = True
game_money = game_money - board.values[piece.location]
return total_throw
def throw():
dice = randint(1,6) + randint(1,6)
return dice
def possession(board):
owns = {}
for i in range(40):
if board.values[i] > 0:
owns[board.names[i]] = False
return owns
if __name__ == "__main__":
main()
。
答案 6 :(得分:0)
简单如下:
Select jobcard.job_id, jobs.labor from jobcard
inner join jobs on jobs.job_id = jobcard.job_id
where jobs.status = 'JobDone';
请注意您所写的内容:
SELECT * FROM `jobs` WHERE Status='JobDone' GROUP BY Job_id
未显示已完成的作业的完整列表,因为您按job_id进行分组。你的陈述的正确之处是:
SELECT * FROM `jobs` WHERE Status='JobDone'