category Item Price
A Pen NULL
B Pen 10
A Pencil 10
B Pencil 8
C Pencil 7
A Note Book 40
B Note Book 30
C Note Book 20
A Bottle NULL
B Bottle 80
A Ball 50
B Ball 40
A Bag 1000
B Bag 800
这是我的数据,我想只显示A类数据,如果A的价格为null 然后显示B类的价格。我试过,但不知道我是如何显示 数据如何使用情况后,凡在SQL Server的条款
select * from tbl1
where category = case when price is null then 'B' else 'A' end
当运行这个查询是只显示A类数据
category Item Price
A Pencil 10
A Note Book 40
A Ball 50
A Bag 1000
输出应该如何? –
你到目前为止尝试过什么? –