我需要按此SQl语句进行排序,以获取
问题是我不知道怎么“点菜”这个
SQL语言:
SELECT DATEPART(DAY,BLG_DATE) as DDay,
datename(month,BLG_DATE) as DMonth,
DATEPART(YEAR,BLG_DATE) as DYear,COUNT(BLG_DATE) as ICount
FROM [BLG]
INNER JOIN [ACC]
ON [BLG].ACC_ID=[ACC].ACC_ID
WHERE [BLG].ACC_ID='1'and [BLG].BLG_DATE LIKE '%2013%' ORDER BY --????
ASP.NET:
<asp:Repeater ID="childRep" runat="server">
<ItemTemplate>
<li><a href="blog.aspx?month=<%# Eval("DMonth") %>"><em><%# Eval("DDay") %></em><%# Eval("DMonth") %><span><%# Eval("ICount") %></span></a></li>
</ItemTemplate>
</asp:Repeater>
我需要DMonth,DDay,DYear和ICount列来填满中继器
注:我只有表BLG(BLG_ID,ACC_ID,BLG_DATE)和ACC(ACC_ID,ACC_USER,ACC_PASS)
最佳答案
这是你要找的吗?
SELECT DATEPART(DAY,BLG_DATE) as DDay,
datename(month,BLG_DATE) as DMonth,
DATEPART(YEAR,BLG_DATE) as DYear ,
(SELECT COUNT(*)
FROM [BLG]
INNER JOIN [ACC] ON [BLG].ACC_ID=[ACC].ACC_ID
WHERE [BLG].ACC_ID='1'and [BLG].BLG_DATE LIKE '%2013%') AS ICount
FROM [BLG]
INNER JOIN [ACC]
ON [BLG].ACC_ID=[ACC].ACC_ID
WHERE [BLG].ACC_ID='1'and [BLG].BLG_DATE LIKE '%2013%'