如果四个表专业名都是按统一顺序排列,则可以用此方法
dim a(1 to count) as integer'全局变量,count为专业数量,
dim i as integer'i于表主键相同
work=选择专业语句'work表示专业for i=1 to count
if work=a(i) then
a(i)=a(i)+1
end if
next
for i=1 to count-1
for j=i+1 to count
if a(i)<a(j) then
tmp=a(i)
a(i)=a(j)
a(j)=tmp
end if
next
next
a()前十个为所求
dim a(1 to count) as integer'全局变量,count为专业数量,
dim i as integer'i于表主键相同
work=选择专业语句'work表示专业for i=1 to count
if work=a(i) then
a(i)=a(i)+1
end if
next
for i=1 to count-1
for j=i+1 to count
if a(i)<a(j) then
tmp=a(i)
a(i)=a(j)
a(j)=tmp
end if
next
next
a()前十个为所求
选中某选项后数组中相应专业加相应分值,最后对数组排序取前十个。
能否说得更详细点!
还有一个问题,也许是我没说清,四个表的专业都在统计范围内,是不是还要讲四个表连起来?还是先分别统计最后在统计一下!
我问一下,假设你多一个兴趣的话是不是又要多一个表呢!?统计不是问题。
先将四个表的数据汇总,(union)
然后
select top 10 * from (select union select union select union select union )