本文介绍了VIEW中的ORDER BY无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有以下视图,如果我使用vwRouteReference作为行数源 用于MS Access表单中的组合框或运行SELECT * FROM vwRouteReference"在SQL查询分析器中,行不会通过Numb排序 。 我在网上看到的所有内容都表明包括TOP 指令应在视图中启用ORDERY BY。有人有这个想法 为什么这个特定视图的排序不正常?谢谢。 创建视图vwRouteReference AS SELECT TOP 100 PERCENT tblItem.ID, tblItem.Numb +'' - ''+ tblQuestion.DescrPrimary AS FullName, tblItem.Numb,tblQuestion.DescrPrimary AS Type FROM tblItem INNER JOIN tblQuestion ON(tblItem.ID = tblQuestion.Item_ID) WHERE(((tblItem.Category_ID)> 0)) UNION SELECT TOP 100 PERCENT tblItem.ID, tblItem.Numb +'' - ''+ tblItem.Type +'':''+ tblItem.Class AS FullName, tblItem.Numb,tblItem.Type +'':''+ tblItem.Class AS Type FROM tblItem WHERE(((tblItem.Type)=''分配''OR(tblItem.Type)=''检查''或 (tblItem.Type)=''路线'')) ORDER BY tblItem.Numb I have the view below and if I use vwRouteReference as the rowsourcefor a combo box in an MS Access form or run "SELECT * FROMvwRouteReference" in SQL Query Analyzer, the rows don''t come throughsorted by Numb. Everything I''ve read on the web suggests that including the TOPdirective should enable ORDERY BY in views. Does someone have an ideawhy the sorting is not working correctly for this particular view? thanks. CREATE VIEW vwRouteReferenceASSELECT TOP 100 PERCENT tblItem.ID,tblItem.Numb + '' - '' + tblQuestion.DescrPrimary AS FullName,tblItem.Numb, tblQuestion.DescrPrimary AS TypeFROM tblItem INNER JOIN tblQuestionON (tblItem.ID = tblQuestion.Item_ID)WHERE (((tblItem.Category_ID)>0))UNIONSELECT TOP 100 PERCENT tblItem.ID,tblItem.Numb + '' - '' + tblItem.Type + '' : '' + tblItem.Class AS FullName,tblItem.Numb, tblItem.Type + '' : '' + tblItem.Class AS TypeFROM tblItemWHERE (((tblItem.Type) = ''Assignment'' OR (tblItem.Type) = ''Check'' OR(tblItem.Type) = ''Route''))ORDER BY tblItem.Numb推荐答案 这篇关于VIEW中的ORDER BY无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-13 17:12