Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: Cross Tab F...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 3538 of 3799
Post > Topic >>

Re: Cross Tab Functions

by scott.marlowe@[EMAIL PROTECTED] ("Scott Marlowe") Jun 20, 2008 at 09:43 PM

I wrote a real simple trunc() function fa****oned after oracles but
used some simple rules to let me have modulo date_trunc.  I don't have
the code anymore.  I might sit down and refigure it out...

On Fri, Jun 20, 2008 at 8:54 PM, Decibel! <decibel@[EMAIL PROTECTED]
> wrote:
> Try using extract instead of to_char. date_trunc might also be of use.
>
> On Jun 20, 2008, at 8:05 AM, Chris Preston wrote:
>
>> Hello All,
>> I have used the cross tab function to setup tables that display months'
>> data, however i need to display years data instead of the months.. so i
>> would display 2006 as a column, 2007 as a colum and 2008 as a column.
when i
>> tried to modify the simple example of the cross tab (shown below)
>> SELECT i.item_name::text As row_name, to_char(if.action_date,
>> 'year')::text As bucket,
>> SUM(if.num_used)::integer As bucketvalue
>> FROM inventory As i INNER JOIN inventory_flow As if
>> ON i.item_id = if.item_id
>> WHERE (if.num_used <> 0 AND if.num_used IS NOT NULL)
>> AND action_date BETWEEN date '2007-01-01' and date '2008-12-31 23:59'
>> GROUP BY i.item_name, to_char(if.action_date, 'year'),
date_part('year',
>> if.action_date)
>> ORDER BY i.item_name, date_part('year', if.action_date);
>>
>> basically i changed the mon and the month to be year.. the system
>> displayed something that i am not sure about. is there a command that
>> converts the year similar to the mon
>>
>> Help again...Please
>
> --
> Decibel!, aka Jim C. Nasby, Database Architect  decibel@[EMAIL PROTECTED]
> Give your computer some brain candy! www.distributed.net Team #1828
>
>
>

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 2 Posts in Topic:
Cross Tab Functions
chris@[EMAIL PROTECTED]   2008-06-20 08:05:48 
Re: Cross Tab Functions
scott.marlowe@[EMAIL PROT  2008-06-20 21:43:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 21:29:23 CST 2008.