Click here to Skip to main content
15,897,291 members
Home / Discussions / Database
   

Database

 
AnswerRe: Can predicates in the WHERE clause affect the type of join Pin
Jörgen Andersson2-Oct-14 10:34
professionalJörgen Andersson2-Oct-14 10:34 
GeneralRe: Can predicates in the WHERE clause affect the type of join Pin
PIEBALDconsult2-Oct-14 10:41
mvePIEBALDconsult2-Oct-14 10:41 
GeneralRe: Can predicates in the WHERE clause affect the type of join Pin
Jörgen Andersson2-Oct-14 10:46
professionalJörgen Andersson2-Oct-14 10:46 
GeneralRe: Can predicates in the WHERE clause affect the type of join Pin
PIEBALDconsult2-Oct-14 11:45
mvePIEBALDconsult2-Oct-14 11:45 
GeneralRe: Can predicates in the WHERE clause affect the type of join Pin
Richard.Berry1002-Oct-14 11:15
Richard.Berry1002-Oct-14 11:15 
AnswerRe: Can predicates in the WHERE clause affect the type of join Pin
Arora_Ankit13-Oct-14 21:06
Arora_Ankit13-Oct-14 21:06 
AnswerRe: Can predicates in the WHERE clause affect the type of join Pin
Member 1115182813-Oct-14 23:38
Member 1115182813-Oct-14 23:38 
QuestionNeed Suggestion for Replacement DB Pin
Kevin Marois30-Sep-14 12:41
professionalKevin Marois30-Sep-14 12:41 
AnswerRe: Need Suggestion for Replacement DB Pin
Mycroft Holmes30-Sep-14 12:52
professionalMycroft Holmes30-Sep-14 12:52 
GeneralRe: Need Suggestion for Replacement DB Pin
Kevin Marois30-Sep-14 12:55
professionalKevin Marois30-Sep-14 12:55 
GeneralRe: Need Suggestion for Replacement DB Pin
Kevin Marois30-Sep-14 12:59
professionalKevin Marois30-Sep-14 12:59 
GeneralRe: Need Suggestion for Replacement DB Pin
Mycroft Holmes30-Sep-14 14:07
professionalMycroft Holmes30-Sep-14 14:07 
GeneralRe: Need Suggestion for Replacement DB Pin
Kevin Marois30-Sep-14 14:31
professionalKevin Marois30-Sep-14 14:31 
GeneralRe: Need Suggestion for Replacement DB Pin
Mycroft Holmes30-Sep-14 14:40
professionalMycroft Holmes30-Sep-14 14:40 
GeneralRe: Need Suggestion for Replacement DB Pin
Jörgen Andersson30-Sep-14 18:54
professionalJörgen Andersson30-Sep-14 18:54 
GeneralRe: Need Suggestion for Replacement DB Pin
Richard MacCutchan30-Sep-14 21:12
mveRichard MacCutchan30-Sep-14 21:12 
GeneralRe: Need Suggestion for Replacement DB Pin
PIEBALDconsult30-Sep-14 13:03
mvePIEBALDconsult30-Sep-14 13:03 
AnswerRe: Need Suggestion for Replacement DB Pin
GuyThiebaut30-Sep-14 21:44
professionalGuyThiebaut30-Sep-14 21:44 
AnswerRe: Need Suggestion for Replacement DB Pin
Eddy Vluggen1-Oct-14 0:59
professionalEddy Vluggen1-Oct-14 0:59 
AnswerRe: Need Suggestion for Replacement DB Pin
jschell3-Oct-14 10:04
jschell3-Oct-14 10:04 
QuestionDyanmic columns and PIVOT? Pin
Tim Carmichael30-Sep-14 6:20
Tim Carmichael30-Sep-14 6:20 
AnswerRe: Dyanmic columns and PIVOT? Pin
Richard Deeming30-Sep-14 7:56
mveRichard Deeming30-Sep-14 7:56 
If I've understood your question properly, you're looking to concatenate row values rather than PIVOT them.

This article[^] covers most of the options. For example, the black-box XML method:
SQL
SELECT
    DataPoint,
    STUFF
    (
        (
            SELECT ',' + Site
            FROM YourTable As I
            WHERE I.DataPoint = O.DataPoint
            ORDER BY Site
            FOR XML PATH(''), TYPE
        ).value('.', 'varchar(max)')
        
        -- Remove the first comma:
        , 1, 1, ''
    ) As Sites
FROM
    YourTable As O
GROUP BY
    DataPoint
;

/*
Output:

DATAPOINT   SITES
-----------------
Power       CH
Temp        CH,KC
WindSpeed   CH,KC
*/

http://sqlfiddle.com/#!3/5657e6/3/0[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Dyanmic columns and PIVOT? Pin
Tim Carmichael30-Sep-14 8:36
Tim Carmichael30-Sep-14 8:36 
GeneralRe: Dyanmic columns and PIVOT? Pin
Richard Deeming30-Sep-14 8:56
mveRichard Deeming30-Sep-14 8:56 
GeneralRe: Dyanmic columns and PIVOT? Pin
Tim Carmichael30-Sep-14 9:00
Tim Carmichael30-Sep-14 9:00 

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.