Viewing 15 posts - 1,711 through 1,725 (of 3,502 total)
Don't understand why you think you need windowing functions...
Does this do what you want? The inner query, inside the parentheses... query "x", gets the counts for each grouping, and then...
November 23, 2016 at 1:37 pm
Self-joins with aggregates. YUCK.
How about something really simple... maybe like this?
SELECT PatientID
, SessionID
, SessionTime
, LAG([SessionTime]) OVER (PARTITION BY PatientID ORDER BY SessionTime) AS PrevSession
FROM
(SELECT 1 AS PatientID, 1 AS SessionID,...
November 21, 2016 at 6:02 pm
Well, you can't turn columns into rows from that... there's nothing to pivot on.
November 21, 2016 at 3:32 pm
Can you please explain the logic of how to get the result you're looking for? Maybe I'm slow, but that part baffles me. Maybe there's something you understand about the...
November 21, 2016 at 2:56 pm
Are there tables with the data in it somewhere that you could share? From your sample data, it's not entirely clear which columns belong in which logical group (table).
1234...
November 21, 2016 at 12:34 pm
Short answer is that it's a cross join of the first 3 columns (all possible combinations) and then outer join back to the original table to pick up the nulls...
November 21, 2016 at 9:47 am
Either you have something wrong in your data or T2 is irrelevant to the question.
Here's my solution with the sample data included. Note that the second table you provide is...
November 19, 2016 at 4:57 pm
Your question forced me to look up the definition of the grain of a table... good thing to do.
Identifying the level of detail
The level of detail that is available in...
November 18, 2016 at 5:16 pm
Can't vouch for any of this, but here's a discussion very similar to what you're trying to do.
November 18, 2016 at 12:28 am
Viewing 15 posts - 1,711 through 1,725 (of 3,502 total)