June 11, 2016 at 5:12 am
Hi Friends,
I have a problem, please help me out.
The table has 2 columns c1, c2.
clc2
A5
B3
C2
Write a SQL query to return the output where column c1 printed column c2 times i.e. A printed 5 times:
A
A
A
A
A
B
B
B
C
C
Thanks in advance,
Durga Prasad.
June 11, 2016 at 7:20 am
This sounds a lot like homework. What have you tried thus far?
June 11, 2016 at 7:35 am
This is an interview question, I have tried with this solution;
SELECT Replicate(c1, c2);
the result I got is:
AAAAA
BBB
CC
June 11, 2016 at 7:50 am
My first question is about the interview. How'd you do? Or is this an online interview or something?
This is entirely possible. Have you heard of a Tally table before? It's also called a table of numbers. I'm asking because I think the interviewer is trying to assess your knowledge of sets versus loops.
If you haven't heard of it, then Jeff's excellent article at http://www.sqlservercentral.com/articles/T-SQL/62867/ is an excellent place to start. To post the answer is simple, but it would skip the learning of a new skill. This is a great opportunity to learn a new skill that will serve you well.
June 11, 2016 at 12:23 pm
Thanks for the reply.
My performance in interview is not up to the mark, but I have positive attitude to learn from my mistakes.
I knew the number table but not by the name, tally table. I will explore and get back.
June 11, 2016 at 1:46 pm
Thanks a lot.
I learned a new thing today from you.
June 12, 2016 at 12:26 pm
durga.palepu (6/11/2016)
Thanks a lot.I learned a new thing today from you.
I'm glad to hear it. Thanks for the feedback.
Please tell me you were able to do it with a single query.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply