假设 我有一个包含USR_NR字段(整数类型)的数据库。而且我知道现场的所有数据。没有任何惊喜。
USR_NR : 1,3,4,7,9,12,44,13,78
我需要将此字段列出为混合格式,例如1,78,44,9,7,3,12,4,13 没有上市规则。我想按照自己想要的方式进行排序。
我尝试过ORDER BY
,但如何前进?
我不能使用ASC
,DESC
SELECT * FROM DB ORDER BY ?
你能帮我吗?
答案 0 :(得分:1)
您需要的是一种表格,您可以使用以下功能为每条记录设置优先级编号:
import wx
from numpy import arange, sin, pi,cos
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.patches as patches
class MainFrame(wx.Frame):
def __init__(self, parent ):
wx.Panel.__init__(self, parent,name="Main", size = (800,800))
self.Panel = Panel(self)
class Panel(wx.Panel):
def __init__(self,parent):
super().__init__(parent)
panel = wx.Panel(self)
self.canvas_panel = CanvasPanel(self)
self.zoom_panel=Zoom(parent=self)
self.zoom_panel2=Zoom2(parent=self)
canvas_sizer = wx.BoxSizer(wx.HORIZONTAL)
canvas_sizer.Add(self.canvas_panel,1,wx.EXPAND)
canvas_sizer.Add(self.zoom_panel,1,wx.EXPAND)
canvas_sizer.Add(self.zoom_panel2,1,wx.EXPAND)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(panel)
sizer.Add(canvas_sizer)
self.SetSizerAndFit(sizer)
self.Show()
class CanvasPanel(wx.Panel):
""" Panel du graphique matplotlib """
def __init__(self, parent , size=(200,350)):
super().__init__(parent)
self.figure = Figure(figsize =(4,4))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
self.Size = self.canvas.Size
self.parent = parent
t = arange(0.5, 3.0, 0.01)
s = cos(2 * pi * t)
self.axes.plot(t, s)
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
self.canvas.mpl_connect('button_press_event', self.on_press)
x = y = 0.02
self.rect = patches.Rectangle((x, y), 0.4,0.4,edgecolor='g', alpha=1, fill=None, label='Label')
self.axes.add_patch(self.rect)
self.axes.plot()
def on_press(self, click):
x1, y1 = click.xdata, click.ydata
zx1 = x1 - 0.2
zy1 = y1 - 0.2
zx2 = x1 + 0.2
zy2 = y1 + 0.2
self.rect.set_x(x1 - 0.2) #Move the rectangle and centre it on the X click point
self.rect.set_y(y1 - 0.2) #Move the rectangle and centre it on the Y click point
self.axes.plot()
self.canvas.draw()
self.zoom_axes=[zx1,zx2,zy1,zy2]
self.parent.zoom_panel.Update(self)
self.parent.zoom_panel2.Update(self)
class Zoom(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self,parent,size=(200,200))
self.Show()
def Update(self,parent):
#Load axis values of the selected rectangle
zoom_axes=parent.zoom_axes
#duplicate the plot from the main panel
self.figure = Figure(figsize =(4,4))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
#Apply axis of drawn rectangle to the plot
self.axes.axis(zoom_axes)
t = arange(0.5, 3.0, 0.01)
s = cos(2 * pi * t)
self.axes.plot(t, s)
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
self.canvas.mpl_connect('button_press_event', self.on_press)
x = y = 0.01
self.rect = patches.Rectangle((x, y), 0.02, 0.02,edgecolor='g', alpha=1, fill=None, label='Label')
self.axes.add_patch(self.rect)
self.axes.plot()
def on_press(self, click):
x1, y1 = click.xdata, click.ydata
zx1 = x1 - 0.01
zy1 = y1 - 0.01
zx2 = x1 + 0.01
zy2 = y1 + 0.01
self.rect.set_x(x1 - 0.01) #Move the rectangle and centre it on the X click point
self.rect.set_y(y1 - 0.01) #Move the rectangle and centre it on the Y click point
self.axes.plot()
self.canvas.draw()
self.zoom_axes=[zx1,zx2,zy1,zy2]
class Zoom2(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self,parent,size=(200,200))
self.Show()
def Update(self,parent):
#Load axis values of the selected rectangle
zoom_axes=parent.zoom_axes
#duplicate the plot from the main panel
self.figure = Figure(figsize =(4,4))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
#Apply axis of drawn rectangle to the plot
self.axes.axis(zoom_axes)
t = arange(0.5, 3.0, 0.01)
s = cos(2 * pi * t)
self.axes.plot(t, s)
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
self.canvas.mpl_connect('button_press_event', self.on_press)
x = y = 0.01
self.rect = patches.Rectangle((x, y), 0.02, 0.02,edgecolor='g', alpha=1, fill=None, label='Label')
self.axes.add_patch(self.rect)
self.axes.add_artist(self.rect)
self.axes.plot()
def on_press(self, click):
x1, y1 = click.xdata, click.ydata
zx1 = x1 - 0.01
zy1 = y1 - 0.01
zx2 = x1 + 0.01
zy2 = y1 + 0.01
self.rect.set_x(x1 - 0.01) #Move the rectangle and centre it on the X click point
self.rect.set_y(y1 - 0.01) #Move the rectangle and centre it on the Y click point
self.axes.plot()
self.canvas.draw()
self.zoom_axes=[zx1,zx2,zy1,zy2]
app = wx.App()
frame = MainFrame(None).Show()
app.MainLoop()
在我的文章中对此进行了详细说明,其中还包括一个演示:
Sequential Rows in Microsoft Access
如果您没有帐户,请浏览链接:阅读全文。
代码也在 GitHub 上:VBA.RowNumbers
答案 1 :(得分:1)
您可以使用instr()
:
order by instr(",1,78,44,9,7,3,12,4,13,", "," & USR_NR & ",")
或者,更详细些,使用switch
:
order by switch(USR_NR = 1, 1,
USR_NR = 78, 2,
USR_NR = 44, 3,
. . .
)