日期:2014-05-18  浏览次数:20451 次

关于数据库分组
创建语句:
--创建食物信息表
create table FoodInfo
(
id int identity primary key,
foodCategoryId int not null foreign key references FoodCategory(id),
foodName nvarchar(10) not null,
--在未使用之前先允许为null
price numeric(18,1),
[state] nvarchar(3) not null,
adminId char(20) not null foreign key references AdminInfo(id),
remarks text default '',
createTime datetime default getdate()
)


食物分类:



现在我想根据食物类别的名称进行分组:我写的语句如下:


------解决方案--------------------
应该是你 FoodInfo.remarks 的问题,
如果你的FoodInfo.remarks内容不多的话,可以这样写 
....
group by ....., cast(FoodInfo.remarks as varchar(max)),....
..
------解决方案--------------------
探讨
应该是你 FoodInfo.remarks 的问题,
如果你的FoodInfo.remarks内容不多的话,可以这样写
....
group by ....., cast(FoodInfo.remarks as varchar(max)),....
..

------解决方案--------------------
探讨
创建语句:
--创建食物信息表
create table FoodInfo
(
id int identity primary key,
foodCategoryId int not null foreign key references FoodCategory(id),
foodName nvarchar(10) not null,
--在未使用之前先允许为null
pric……