Solved

Need to create new output column

Posted on 2014-03-26
3
169 Views
Last Modified: 2014-03-26
I need to create a new output column in a query that will be used as a index.  I    can not use the existing field for security reasons (Col A)  So I must generate a new column (Col B)
Lets say that Col A is a Social Security Number and a call center person can not see it so we will create a new field Col B.  Later internally we will re associate the records.

Col A exists in the table Col B does not.  I can not modify the table

How can I create a query to do this.  A stored procedure will be ok as long as it produces a result set that I can see and export

Example

TableX

Col A           Col B
163777439     1
163777439     1
163777439     1
163777439     1
163777439     1
163777439     1
718108418     2
718108418     2
718108418     2
918233645     3
918233645     3
418323022     4
418323022     4
418323022     4
418323022     4
418434193     5
418434193     5
418434193     5
418434193     5
0
Comment
Question by:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39957778
So ... is the point of the 1, 2, 3, 4, 5 numbers in Column B just to have a 'placeholder' to Column A?

If so, and you want it in a query, meaning the 1, 2, 3, 4, 5 won't be stored in a table, you can just use a RANK statement, sorted by whatever floats your boat...

SELECT ColA, RANK() OVER (ORDER BY ColA) as ColB
FROM YourTable
0
 

Author Closing Comment

by:Charles Baldo
ID: 39957790
Thank You
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39957794
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question