Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL
Here is the base table structure
 
ID RegNo NewID NewRegNo
1 a001 - -
2 a002 - -
3 a003 1 a004
4 a005 - -
5 a006 2 a007
6 a008 3 a008
 
Now i want to get this
 
ID RegNo
1 a001
2 a002
3 a004
4 a005
5 a007
6 a008
Posted 23-Sep-12 21:15pm
Edited 23-Sep-12 21:16pm
v2
Comments
Abhijit Parab at 24-Sep-12 2:19am
   
what you want to show all RegNo or all NewIds in a single column?
biswarup88 at 24-Sep-12 2:21am
   
i want to bind RegNo and NewRegNo..and display that with ID

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
you can use case when syntax for that.
Try the following query for that.
 
select id,
regno = case when NewRegNo is null then RegNo else NewRegNo end
from Table_1
 
Thanks,
Viprat
  Permalink  
Comments
biswarup88 at 24-Sep-12 2:25am
   
Thanks viprat..for your help
VIPR@T at 24-Sep-12 2:29am
   
you wellcome..

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 385
1 DamithSL 210
2 Kornfeld Eliyahu Peter 210
3 OriginalGriff 180
4 Peter Leow 95
0 OriginalGriff 7,215
1 DamithSL 5,199
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,757
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100