Re: storing data horizontal vs vertical using pl/sql

  • From: Connor McDonald <mcdonald.connor@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Thu, 19 Jan 2006 17:20:06 +0800

horizontal to vertical:

insert into T ( domain, col_type, val)
select domain, 1, col1
union all
select domain, 2, col2
union all
select domain, 3, col4
etc...

vertical to horizontal

insert into T ( domain, col1, col2, col3, ... )
select
  dom,
  max(decode(col_type,1,val,null),
  max(decode(col_type,2,val,null),
  max(decode(col_type,3,val,null)
  ...
group by dom

hth
Connor




On 1/19/06, Norman Dunbar <norman.dunbar@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> Apologies to all 'confused' readers of my posts.
>
> The system we have for email is a bit strange when it inserts my
> signature block. For some reason, it sometimes inserts in a totally
> random place. I've no idea why - but it has caused some confusion in the
> past.
>
> Technology - who needs it ?
>
> Cheers,
> Norman.
>
> PS. I wonder where it will go this time .......
>
> Norman Dunbar.
> Contract Oracle DBA.
> Rivers House, Leeds.
>
> Internal : 7 28 2051
> External : 0113 231 2051
>
>
> Information in this message may be confidential and may be legally
> privileged. If you have received this message by mistake, please notify the
> sender immediately, delete it and do not copy it to anyone else.
>
> We have checked this email and its attachments for viruses. But you should
> still check any attachment before opening it.
>
> We may have to make this message and any reply to it public if asked to
> under the Freedom of Information Act, Data Protection Act or for
> litigation.  Email messages and attachments sent to or from any Environment
> Agency address may also be accessed by someone other than the sender or
> recipient, for business purposes.
>
> If we have sent you information and you wish to use it please read our
> terms and conditions which you can get by calling us on 08708 506 506.  Find
> out more about the Environment Agency at www.environment-agency.gov.uk
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


--
Connor McDonald
===========================
email: connor_mcdonald@xxxxxxxxx
web:   http://www.oracledba.co.uk

"Semper in excremento, sole profundum qui variat"

Other related posts: