Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Oct 11, 1999

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 WORD1
CASE 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.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date