devxlogo

Redundancy After SELECT

Redundancy After SELECT

Question:
I need to have a result from a SELECT query with all the rows containing “word1” in column 1 and all the rows containing “word2” in column 2.

If a row contains both, I want it to appear twice. What query should I do?

Answer:
I’m not sure I understand your question, but check your docs for conditional statements and you might try something along the lines of the following:

SELECT CASE when PATINDEX('WORD1',COLUMN1)>0 then WORD1CASE when PATINDX('WORD2',COLUMN2)>0 then WORD2

In the big picture of things, you are trying to construct a cross tab. The limitations of the technique are that you have to know how many groups you need to end up with, so while the populations of word are small this will work.

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist