Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Break up a field into multiple rows

Re: Break up a field into multiple rows

From: Todd Benson <toddb_at_spectralogic.com>
Date: 30 Oct 2002 10:00:13 -0800
Message-ID: <97b61782.0210301000.75832c9b@posting.google.com>


Thanks, this makes sense. My only problem is that I cannot write this as a view in MS SQL server. Any one know why? It simply errors out and complains that there are no output columns or from clause.

Todd

"Tibor Karaszi" <tibor_not_pressed_ham_.karaszi_at_cornerstone.se> wrote in message news:<Ewvu9.1454$1r1.44981_at_newsc.telia.net>...
> Todd,
>
> Here's a "brute force" method, using some string manipulation and a UNION.
> Dialect is MS Transact-SQL. The CHARINDEX function find the position of the
> first expression within the second expression.
>
> SELECT
> order_number
> ,sales_rep
> ,item
> ,quantity
> ,LEFT(territories, CHARINDEX(' ', territories))
> FROM sales_orders
> UNION ALL
> SELECT
> order_number
> ,sales_rep
> ,item
> ,quantity
> ,RIGHT(territories, CHARINDEX(' ', territories))
> FROM sales_orders
>
> --
> Tibor Karaszi
Received on Wed Oct 30 2002 - 12:00:13 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US