SQL查询非常紧急 [英] SQL Query very urgent

查看:76
本文介绍了SQL查询非常紧急的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,
有关SQL查询的帮助:
我的桌子是这样的:

Hi friends,
Want Help on SQL query:
My table is something like this:

CREATE TABLE [dbo].[chapter_report](
    [qno] [int] NULL,
    [chapter] [varchar](max) ,
    [Topic] [varchar](max) ,
    [Status] [bit] NULL)




我想要以status = 1为标记的不同章节,如果status = 0,则相应的章节名称应为零.
章节列可以具有多个重复值,并且状态包含0到1,




i want distinct chapter with status=1 as marks, if status=0 then the corresponding chapter name should have zero.
chapter column can have multiple duplicate values ans status contains 0''s and 1''s,

推荐答案

在查询中使用case语句.

例如,类似select distinct(case when status =1 chapter else 0 end from chapter_report .
的东西 这可能无法正常工作,但应该可以给您一些提示.
Use a case statement in your query.

For example, something like select distinct(case when status =1 chapter else 0 end from chapter_report .
This may not work exactly but it should give you some idea.


这篇关于SQL查询非常紧急的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆