如何编写单个查询以显示我的第一个记录将被放置在最后位置

时间:2017-07-14 09:20:01

标签: mysql sql

如果我有1,2 ......... 1000个员工姓名和id但我希望我的输出像2,3,4,......... 1000,1。谁是第一个emp名称,应放在最后..在这种情况下,我已经使用了联合所有的概念它是有效的。但没有使用联合所有概念 怎么可能?

1 个答案:

答案 0 :(得分:1)

使用条件from collections import defaultdict import matplotlib.pyplot as plt import matplotlib.dates as dates from itertools import groupby from datetime import datetime import csv data = defaultdict(list) with open('input2.txt', 'rb') as f_input: csv_input = csv.reader(f_input, delimiter=' ', skipinitialspace=True) header = next(csv_input) for row in csv_input: row.append(datetime.strptime(row[1], '%Y-%m-%d')) row.append(dates.date2num(row[4])) data[row[0]].append(row) bbox = dict(facecolor='blue', alpha=0.1, pad=1.0) for rows in data.values(): fig = plt.figure(figsize=(10, 2)) ax = fig.add_subplot(111) # Get date range d = sorted(row[5] for row in rows) ax.set_xlim(d[0]-10, d[-1]+10) ax.set_ylim(0, 0.8) for k, g in groupby(sorted(rows), lambda x: x[4]): rows = list(g) text = '{}\n\n{}'.format(k.day, '\n'.join([row[2] for row in rows])) ax.scatter(rows[0][5], 0.1, s=5, c='black') ax.text(row[5], 0.15, text, ha="center", va="bottom", fontsize=7.0, bbox=bbox) fig.suptitle(row[0]) fig.subplots_adjust(bottom=0.2) # Add space at bottom ax.xaxis.set_major_locator(dates.MonthLocator()) #ax.xaxis.set_minor_locator(dates.DayLocator()) ax.xaxis.set_major_formatter(dates.DateFormatter('%Y\n%m')) ax.yaxis.set_ticks([]) plt.show() 子句:

ORDER BY