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 20:15pm
Edited 23-Sep-12 20: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
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 450
1 Sergey Alexandrovich Kryukov 350
2 Shai Vashdi 318
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 9,109
1 OriginalGriff 5,290
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


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