Hi Jeremy,
Sorry about that. I misunderstood on what you need.
Here is the SQL statement
SELECT NAME,
dates,
source
FROM (SELECT NAME,
a_date,
b_date,
c_date
FROM test
WHERE NAME = 'TOM') AS p1
UNPIVOT ( dates
FOR source IN (a_date,
b_date,
c_date) ) AS p2;
so what I want is to have "p1" come from Sequel::Dataset (ie: Test.toms,
Test.joes, etc) instead of hard code it into this SQL statement.
thank you Jeremy.
Kenneth
On Wednesday, June 20, 2018 at 12:40:23 PM UTC-7, Jeremy Evans wrote:
>
> On Wednesday, June 20, 2018 at 10:23:02 AM UTC-7, lkfken wrote:
>>
>> Hi Jeremy,
>>
>> Table TEST
>>
>> NAME A_DATE B_DATE C_DATE
>> ----------------------------------------------------
>> JOE 1/1/2009 1/1/2010 1/1/2011
>> TOM 2/1/2010 3/1/2009 5/1/2016
>> ----------------------------------------------------
>>
>> class Test < Sequel::Model
>>
>> dataset_module do
>> def toms
>> where(:name => 'TOM')
>> end
>> end
>>
>> end
>>
>>
>> this is where I got stuck now.
>>
>> I want to unpivot on those 3 date columns from the result set
>> (Test.toms). So the expected result set would become
>>
>>
>> NAME DATES SOURCE
>> ----------------------------------------------------
>> TOM 2/1/2010 A_DATE
>> TOM 3/1/2009 B_DATE
>> TOM 5/1/2016 C_DATE
>> ----------------------------------------------------
>>
>> Thank you for your help.
>>
>
> At the risk of being redundant: if you post the SQL you want to use, then
> I can probably help you with the Sequel part. I realize that that
> statement does not logically imply that if you don't post the SQL you want
> to use, I don't think I can help you, but most people would correctly infer
> that. Sorry to be cheeky about this. :)
>
> Thanks,
> Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.