Click here to Skip to main content
12,304,822 members (67,775 online)
Rate this:
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
Abhijit Parab 24-Sep-12 2:19am
what you want to show all RegNo or all NewIds in a single column?
biswarup88 24-Sep-12 2:21am
i want to bind RegNo and NewRegNo..and display that with ID

1 solution

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

Solution 1


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

biswarup88 24-Sep-12 2:25am
Thanks viprat..for your help
VIPR@T 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2016
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