日期:2014-05-17  浏览次数:21175 次

SQL查询语句怎么写成ASP语句?请各位大虾帮忙!
drop   view   V_FindStoreQty
go
Create   View   V_FindStoreQty
as
--库存查询VIEW
SELECT   A.FCode,A.FName,A.FUnitName,isnull(B.FCostPrice,0.00)   as   FCostPrice,isnull(B.FQty,0)   as   FQty,isnull(B.   FMoney,0)   as   FMoney,
            A.FTypeID,C.FName   as   FTypeName,A.FSpec,B.FNewStore,B.FWHName  
            FROM   FProductionMg   A
LEFT   JOIN   (select   T1.FmatCode,T1.FNewStore,T2.FName   as   FWHName,Count(*)   as   FQty,
                        Sum(T1.FCostPrice)   As   FMoney,Sum(T1.FCostPrice)/Count(*)   as   FCostPrice
                        FROM   FWhouseBarCode   T1
                        LEFT   JOIN   FWhoseStore   T2
                        ON   T1.FNewStore=T2.FCode
                        Group   by   FmatCode,FNewStore,T2.FName   )       B
ON         A.FCode=B.FMatCode
LEFT   JOIN   FType   C
ON       A.FTypeID=C.FCode  


请问上面SQL   查询语句怎么写成ASP语句     请各位大虾帮忙

------解决方案--------------------
'=================================================
'函数名:GetPageSQL
'作 用:生成分页的SQL语句
'参 数:flds ----SQL语句查询的列名
' tblName ----SQL语句查询的表名
' tblPK ----SQL语句查询定位的字段名
' strWhere ----SQL语句的Where条件,不带Where
' OrderType ----排序类型,升序还是降序,不带Order By
' PageSize ----分页中每一页的记录显示数目
' PageIndex ----当前页码
'返回值:GetPageSQL ----欲执行查询的SQL语句
'=================================================
Function GetPageSQL(flds,tblName,tblPK,strWhere,OrderType,PageSize,PageIndex)

Dim strTemp,strSQL,strOrder,strTmp,GetPageSize,GetRecords,GetPages,GetPageIndex

GetPageSize=SetPageSize(PageSize)

GetRecords=SetRecords(tblName,strWhere)

GetPages=SetPages(GetRecords,GetPageSize)

GetPageIndex=SetCurrentPage(PageIndex,GetPages)

If OrderType=0 Then
strTemp= "> (select max([ " & tblPK & "]) "
strOrder= " order by [ " & tblPK & "] asc "
Else
strTemp= " <(select min([ " & tblPK & "]) "
strOrder= " order by [ " & tblPK & "] desc "
End If

If GetPageIndex=1 Then
strTemp= " "
If strWhere <> " " Then
strTmp = " where " + strWhere
End If
If flds <> " " Then
strSQL = "select Distinct top " & GetPageSize & " "&flds& " from " & tblName & " " & strTmp & strOrder
Else
strSQL = "select Distinct top " & GetPageSize & " * from " & tblName & " " & strTmp & strOrder
End If
Else
If flds <> " " Then
strSQL= "select