62,073
社区成员
发帖
与我相关
我的任务
分享
create table testtable
(
price varchar(10)
)
insert into testtable values ('100')
select * from testtable where CONVERT(decimal,price) = 100
drop table testtable
[/quote]
大师太片面了
create table testtable
(
price varchar(10)
)
insert into testtable values ('100')
insert into testtable values ('a')
select * from testtable where CONVERT(decimal,price) = 100
drop table testtable
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.
select * from
(select
id,
max(case pkey when '价格' then valint else 0 end) as '价格',
(select top 1 valstring from table2 where id=t.id and pkey='品牌') as '品牌',
(select top 1 valstring from table2 where id=t.id and pkey='颜色') as '颜色'
from table2 t
group by id) as tt
where 价格 between 8 and 10 and 颜色='red' and 品牌='大众'
[/quote]
是这样的,谢谢啦!
这样表设计的合理吗?
create table testtable
(
price varchar(10)
)
insert into testtable values ('100')
select * from testtable where CONVERT(decimal,price) = 100
drop table testtable