sqlserver支持top关键字,返回前100条数据。select top 100 * from table;// 返回前100行数据
成都创新互联-专业网站定制、快速模板网站建设、高性价比长顺网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式长顺网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖长顺地区。费用合理售后完善,十年实体公司更值得信赖。
mysql支持limit,一个参数:select * from table limit 100; //返回前100行记录
Oracle需要使用rownum。select * from table where rownum=100; //返回前100条数据
TOP 子句
TOP 子句用于规定要返回的记录的数目。
对于拥有数千条记录的大型表来说,TOP 子句是非常有用。
SQL Server 的语法:
SELECT TOP number|percent column_name(s)
FROM table_name
limit子句用于强制select语句返回置顶的记录数,参数必须是整数常量。一个参数是返回前几条记录;两个参数时,第一个参数指定第一个返回记录行的偏移量(初始记录行的偏移量是0),第二个参数指定返回记录的最大数目。
添加listbox1,label1,command1
Public Class Form1
Dim N(10) As Integer
'生成随机数
Private Sub CreatRand()
Dim I As Integer
Dim Strarr As String
Strarr = ""
ListBox1.Items.Clear()
Dim R As New System.Random
For I = 0 To 9
N(I) = R.Next(30, 100)
ListBox1.Items.Add(Str(N(I)))
Strarr = Strarr Str(N(I)) " "
Next
'添加标签的横向数字序列
Label1.Text = Strarr
End Sub
'获取最大值
Private Function GetMax() As Integer
Dim I As Integer
Dim intMax As Integer
intMax = 0
For I = 0 To 9
intMax = IIf(intMax N(I), intMax, N(I))
Next
Return intMax
End Function
'获取最小值
Private Function GetMin() As Integer
Dim I As Integer
Dim intMin As Integer
intMin = 101
For I = 0 To 9
intMin = IIf(intMin N(I), intMin, N(I))
Next
Return intMin
End Function
'获取平均值
Private Function GetAve() As Single
Dim I As Integer
Dim Sum As Integer
Sum = 0
For I = 0 To 9
Sum = Sum + N(I)
Next
Return Sum / 10
End Function
'生成随机数,显示各种值
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call CreatRand()
MsgBox("最大值=" Str(GetMax()) ",最小值=" Str(GetMin()) ",平均值=" Str(GetAve()))
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j
j = GetRndNotRepeat(1, 10, 10)
If j(0) Then
For i = 1 To 10
MsgBox(j(i))
Next
End If
End Sub
Public Function GetRndNotRepeat(ByVal NumMin As Integer, ByVal NumMax As Integer, ByVal n As Integer)
'编制:xsfhlzh
'功能:取NumMin到NumMax间的n个随机整数
'说明:取数标志数组是Byte,每一位表示NumMin到NumMax间某个数的状态
Dim arr() As Integer
If n NumMax - NumMin + 1 Then
ReDim arr(0)
arr(0) = 0
Return arr
Else
ReDim arr(n)
Dim m As Integer
Dim b() As Byte
m = Int((NumMax - NumMin) / 8)
ReDim b(m)
'取数标志
Dim i
Dim x, y, z As Integer
Randomize()
arr(0) = 1
For i = 1 To n
Do
'找到x的位置,y表示x在数组的第几个字节,z表示x在该字节的第几位
x = Int(Rnd() * (NumMax - NumMin + 1)) + NumMin
y = x - NumMin
z = 2 ^ (y Mod 8)
y = y \ 8
Loop While b(y) And z
b(y) = b(y) Or z
arr(i) = x
'找到未取的数,并放入数组,设置标志位
Next i
End If
Return arr
End Function