Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to create new output column

Posted on 2014-03-26
3
Medium Priority
?
174 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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 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