Click here to Skip to main content
15,867,851 members
Home / Discussions / Database
   

Database

 
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 
AnswerRe: Dyanmic columns and PIVOT? Pin
Richard Deeming30-Sep-14 9:15
mveRichard Deeming30-Sep-14 9:15 
GeneralRe: Dyanmic columns and PIVOT? Pin
Tim Carmichael30-Sep-14 9:27
Tim Carmichael30-Sep-14 9:27 
QuestionXML select Pin
byka30-Sep-14 2:50
byka30-Sep-14 2:50 
AnswerRe: XML select Pin
Kornfeld Eliyahu Peter30-Sep-14 3:32
professionalKornfeld Eliyahu Peter30-Sep-14 3:32 
QuestionHow to select rows from table using Name field in sql Pin
netsheiksf29-Sep-14 21:22
netsheiksf29-Sep-14 21:22 
AnswerRe: How to select rows from table using Name field in sql Pin
Jörgen Andersson29-Sep-14 21:36
professionalJörgen Andersson29-Sep-14 21:36 
Questionhow to select last row on second CTE Pin
mamatsiantar28-Sep-14 18:06
mamatsiantar28-Sep-14 18:06 
AnswerRe: how to select last row on second CTE Pin
Bernhard Hiller28-Sep-14 22:30
Bernhard Hiller28-Sep-14 22:30 
GeneralRe: how to select last row on second CTE Pin
Jörgen Andersson28-Sep-14 23:42
professionalJörgen Andersson28-Sep-14 23:42 
GeneralRe: how to select last row on second CTE Pin
Eddy Vluggen29-Sep-14 5:26
professionalEddy Vluggen29-Sep-14 5:26 
GeneralRe: how to select last row on second CTE Pin
Jörgen Andersson29-Sep-14 5:50
professionalJörgen Andersson29-Sep-14 5:50 
QuestionMS Server - Lock a record Pin
hansoctantan26-Sep-14 3:48
professionalhansoctantan26-Sep-14 3:48 
QuestionRe: MS Server - Lock a record Pin
ZurdoDev26-Sep-14 4:22
professionalZurdoDev26-Sep-14 4:22 
AnswerRe: MS Server - Lock a record Pin
PIEBALDconsult26-Sep-14 4:24
mvePIEBALDconsult26-Sep-14 4:24 

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.