Re: (ot) SQL Question - flattening data

2009-11-15 Thread Dominic Watson
Depending on what you are doing with this data, seems to me that this should be done in the front end and not the db. So get your data in the original format: USER, CODE rick,AL rick,FR rick,TR rick,HS joe,AL joe,FU Bob,FM And then use cfoutput with query and group (a very rough output here):

Re: (ot) SQL Question - flattening data

2009-11-15 Thread Dominic Watson
Just read the original post properly - please ignore me. Dominic 2009/11/15 Dominic Watson watson.domi...@googlemail.com Depending on what you are doing with this data, seems to me that this should be done in the front end and not the db. So get your data in the original format: USER,

RE: (ot) SQL Question - flattening data

2009-11-14 Thread Dave Phelan
You wrote a pivot query without using pivot. BTW, the aggregate for the pivot query can be Count(). -Original Message- From: Rick Root [mailto:rick.r...@gmail.com] Sent: Friday, November 13, 2009 4:19 PM To: cf-talk Subject: Re: (ot) SQL Question - flattening data From

(ot) SQL Question - flattening data

2009-11-13 Thread Rick Root
I'm trying to flatten out some data using only SQL we currently have a mainframe job that produces a datafeed for me uses cobol to do the work of looping through all the entities and putting up to 5 record types in 5 record type fields in the output file. I'm trying to figure out a way

RE: (ot) SQL Question - flattening data

2009-11-13 Thread Dave Phelan
X Crosstab queries can be a little hairy to build. IMHO, go with the cursors. -Original Message- From: Rick Root [mailto:rick.r...@gmail.com] Sent: Friday, November 13, 2009 10:41 AM To: cf-talk Subject: (ot) SQL Question - flattening data I'm

RE: (ot) SQL Question - flattening data

2009-11-13 Thread DURETTE, STEVEN J (ATTASIAIT)
] Sent: Friday, November 13, 2009 1:11 PM To: cf-talk Subject: RE: (ot) SQL Question - flattening data Is there a particular reason to return them in this format? I would think that the straight query output would be simpler to work with. However, you can accomplish this either by using cursors

Re: (ot) SQL Question - flattening data

2009-11-13 Thread Rick Root
From the documentation, pivot tables seem to require aggregate functions... The generic description would seem to work but the examples make it difficult to see how. But... I figured out a solution! Using SQL Server's row_number() over (partition by XXX order by XXX) I can make a subquery that