Click here to Skip to main content
15,910,224 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
Want Help on SQL query:
My table is something like this:

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



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,
Posted
Updated 8-Feb-12 20:38pm
v2

1 solution

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.
 
Share this answer
 
Comments
Espen Harlinn 9-Feb-12 8:36am    
5'ed!
Abhinav S 9-Feb-12 12:07pm    
Thank you Espen.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900