-4

我目前正在尝试使用名为“Registration”2 列的 sql 数据库表在我的表单中显示一条记录。信息将显示在gridview中

下面是表格:

Registration ID           Date Registered
    1                          10/4/2013
    2                          11/4/2013
    3                          12/5/2013
    4                          13/6/2013

结果将是:

Number of record           Month Registered
2                          April
1                          May
1                          June

有谁知道查询是什么?

4

4 回答 4

1

您可以尝试类似下面的 SQL 来检索数据

select  count(*) as Numberofrecord, datename(month, DateRegistered) as MonthRegistered 
from table
group by datename(month, DateRegistered) 
于 2013-08-06T05:06:33.123 回答
1

试试这个

select count(*) as NumberOfRegister,DATENAME(MONTH,DateRegisterd)  as MonthRegistered 
from table_name
group by  DATENAME(MONTH,DateRegisterd) 
于 2013-08-06T05:08:39.100 回答
1

试试这个 :

Select Count(*)  As NumberOfRecord, DATENAME(month, DateRegistered) As MonthRegistered  
from TableName GRoup by DATENAME(month, DateRegistered)
于 2013-08-06T05:10:44.423 回答
1

如果你想从 SQL 中获取记录,那么试试这样的

SELECT MONTH(DateRegisterd) MONTH, COUNT(*) COUNT
FROM YourTableName
WHERE YEAR(DateRegisterd)=2013//If you want records of particular year
GROUP BY MONTH(DateRegisterd)

或者像这样

select  count(*) as Numberofrecord, datename(month, Date_Registered) as MonthRegistered 
from YourTable group by datename(month, Date_Registered) 
于 2013-08-06T05:19:48.230 回答