Classic ASP - display records from databse in the table Week-wise or month-wise

冷暖自知 提交于 2019-12-13 04:29:49

问题


I'm using asp code i.e classic ASP and SQL server 2000 in this process to display records from database into a table. I have two links called week-wise and month-wise . when the user clicks on this link he will see the data week-wise or month-wise assuming the database have a date field which stores all the dates, when the record is inserted.

So far i'm able to display records present in the table for that particular user. How can i display his/her records WEEK or MONTH wise.

this is the query that I have use

<%
    sql="select SUM(grand_total) as total from order_details where emp_number='"&request.QueryString("no")&"'"
    rs.open sql,con,1,2
    do while not rs.eof

        rs.movenext
    loop
    rs.close
%>

this particular query displays records of that particular result...


回答1:


select
emp_number,
datepart(year, order_date),
datepart(month, order_date),
datepart(wk, order_date),
sum(grand_total)
from order_details
group by
emp_number,
datepart(year, order_date),
datepart(month, order_date),
datepart(wk, order_date)
order by 1, 2, 3, 4

And I'd consider using Prepared Statements to prevent SQL injection.



来源:https://stackoverflow.com/questions/10633618/classic-asp-display-records-from-databse-in-the-table-week-wise-or-month-wise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!