Click here to Skip to main content
15,917,875 members
Home / Discussions / Database
   

Database

 
QuestionConverting last N columns to rows in sql server Pin
sumit703410-Mar-11 17:18
sumit703410-Mar-11 17:18 
AnswerRe: Converting last N columns to rows in sql server Pin
Mycroft Holmes10-Mar-11 18:28
professionalMycroft Holmes10-Mar-11 18:28 
GeneralRe: Converting last N columns to rows in sql server Pin
sumit703410-Mar-11 18:36
sumit703410-Mar-11 18:36 
GeneralRe: Converting last N columns to rows in sql server Pin
Mycroft Holmes10-Mar-11 18:41
professionalMycroft Holmes10-Mar-11 18:41 
AnswerRe: Converting last N columns to rows in sql server Pin
Pravin Patil, Mumbai10-Mar-11 20:35
Pravin Patil, Mumbai10-Mar-11 20:35 
AnswerRe: Converting last N columns to rows in sql server Pin
J4amieC10-Mar-11 23:57
J4amieC10-Mar-11 23:57 
QuestionFlatten data (SQL) Pin
Lash2010-Mar-11 4:46
Lash2010-Mar-11 4:46 
AnswerRe: Flatten data (SQL) Pin
Wendelius10-Mar-11 5:45
mentorWendelius10-Mar-11 5:45 
The column headers seem like you want to select the person with the same first, middle OR last name but your results seem like you would select only based on the same last name. However, basically you would use self join. If the last name is used to match rows, it could be something like:
SELECT a.*, b.*
FROM tblPersonName a LEF OUTER JOIN tblPersonName b
     ON a.lname = b.lname

This query has problems though (depending on your specs). If you have three persons with the same last name you get those on multiple rows (each pair). Also each pair will be listed twice (both ways), but I'm not able to say if that's what you want.

Also the ID field seems quite suspicious. Do you really have several rows with the same id? If not, that could be used to eliminate the pairs from being listed twice (again if that's what you want).
The need to optimize rises from a bad design.My articles[^]

GeneralRe: Flatten data (SQL) Pin
Lash2010-Mar-11 5:54
Lash2010-Mar-11 5:54 
GeneralRe: Flatten data (SQL) Pin
Wendelius10-Mar-11 6:19
mentorWendelius10-Mar-11 6:19 
GeneralRe: Flatten data (SQL) Pin
Lash2010-Mar-11 7:10
Lash2010-Mar-11 7:10 
GeneralRe: Flatten data (SQL) Pin
Wendelius10-Mar-11 7:24
mentorWendelius10-Mar-11 7:24 
AnswerRe: Flatten data (SQL) Pin
i.j.russell11-Mar-11 1:30
i.j.russell11-Mar-11 1:30 
GeneralRe: Flatten data (SQL) Pin
Lash2011-Mar-11 4:32
Lash2011-Mar-11 4:32 
QuestionReport Builder 3.0 Pin
kunthavai10-Mar-11 4:14
kunthavai10-Mar-11 4:14 
AnswerRe: Report Builder 3.0 Pin
Klaus-Werner Konrad16-Mar-11 8:32
Klaus-Werner Konrad16-Mar-11 8:32 
QuestionSQL Server 2005 Express Pin
arkiboys9-Mar-11 21:18
arkiboys9-Mar-11 21:18 
AnswerRe: SQL Server 2005 Express Pin
Wendelius9-Mar-11 22:32
mentorWendelius9-Mar-11 22:32 
QuestionA Matter Of Design Pin
Roger Wright9-Mar-11 16:21
professionalRoger Wright9-Mar-11 16:21 
AnswerRe: A Matter Of Design Pin
Jörgen Andersson9-Mar-11 19:13
professionalJörgen Andersson9-Mar-11 19:13 
AnswerRe: A Matter Of Design Pin
Mycroft Holmes9-Mar-11 22:13
professionalMycroft Holmes9-Mar-11 22:13 
AnswerRe: A Matter Of Design Pin
David Skelly9-Mar-11 22:30
David Skelly9-Mar-11 22:30 
AnswerRe: A Matter Of Design Pin
Tim Carmichael10-Mar-11 3:02
Tim Carmichael10-Mar-11 3:02 
AnswerRe: A Matter Of Design Pin
Wendelius10-Mar-11 6:05
mentorWendelius10-Mar-11 6:05 
Questioncompare two tables in different environments. Pin
vanikanc9-Mar-11 11:01
vanikanc9-Mar-11 11:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.