Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 20th, 2005, 07:20 PM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default to different result column basic on some condition

say I have a table like this:

date delete
---- ----
12/3 0
12/4 1


I need a sql to give me this result basic on the "delete" column:
complete date delete date
------------- -----------
12/0
                12/4

how??

thanks!!

 
Old December 21st, 2005, 11:27 AM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One way
the create table and insert is just for testing you would only modify the select statement below
create table testBla (date datetime, del bit)
insert into testBla
select '12/3/2005',0 union all
select '12/4/2005',1

select case when del =0 then date else null end CompleteDate,
case when del = 1 then date else null end DeleteDate from
testBla

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" -- http://sqlservercode.blogspot.com/





Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView and SQL More than one result = one result DarkForce ASP.NET 2.0 Basics 0 July 20th, 2007 04:29 AM
where condition...? mnr555 Crystal Reports 0 June 18th, 2006 05:32 PM
using Result form previous column... filipczako SQL Language 4 November 28th, 2005 05:41 PM
Condition mateenmohd SQL Server 2000 6 May 6th, 2004 03:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.