Posted by David Portas on 02/01/06 17:01
kalikoi@gmail.com wrote:
> Hi
>
> If i use select * from table...i get the following
>
>
> 10 Energy Energy Energy Equipment & Services Oil & Gas
> Drilling 10101010
> 10 Energy Energy Energy Equipment & Services Oil & Gas
> Equipment & Svcs 10101020
> 10 Energy Energy Oil & Gas Integrated Oil &
> Gas 10102010
> 10 Energy Energy Oil & Gas Oil & Gas
> Exploration & Prod 10102020
> 10 Energy Energy Oil & Gas Oil & Gas Refining
> & Mktg 10102030
> 10 Energy Energy Oil & Gas Oil & Gas Storage
> & Transpor 10102040
> 10 Energy Energy Oil & Gas Coal & Consumable
> Fuels 10102050
> 15 Materials Materials Chemicals Commodity
> Chemicals 15101010
> 15 Materials Materials Chemicals Diversified
> Chemicals 15101020
> 15 Materials Materials Chemicals Fertilizers & Agri
> Chemicals 15101030
> 15 Materials Materials Chemicals Industrial
> Gases 15101040
> 15 Materials Materials Chemicals Specialty
> Chemicals 15101050
> 15 Materials Materials Construction Materials Construction
> Materials 15102010
> 15 Materials Materials Containers & Packaging Metal & Glass
> Containers 15103010
> 15 Materials Materials Containers & Packaging Paper
> Packaging 15103020
> 15 Materials Materials Metals & Mining
> Aluminum 15104010
> 15 Materials Materials Metals & Mining Diversified Metals
> & Mining 15104020
> 15 Materials Materials Metals & Mining Gold 15104030
> 15 Materials Materials Metals & Mining Precious Metals &
> Minerals 15104040
> 15 Materials Materials Metals & Mining Steel 15104050
> 15 Materials Materials Paper & Forest Products Forest
> Products 15105010
> 15 Materials Materials Paper & Forest Products Paper
> Products 15105020
>
>
> but my output should be as follows
>
>
> 10 Energy Energy Energy Equipment & Services Oil & Gas
> Drilling 10101010
> Oil & Gas Equipment & Svcs 10101020
> 10 Energy Energy Oil & Gas Integrated Oil &
> Gas 10102010
> Oil & Gas Exploration & Prod 10102020
> Oil & Gas Refining & Mktg 10102030
> Oil & Gas Storage & Transpor 10102040
> Coal & Consumable Fuels 10102050
> 15 Materials Materials Chemicals Commodity
> Chemicals 15101010
> Diversified Chemicals 15101020
> Fertilizers & Agri Chemicals 15101030
> Industrial Gases 15101040
> Specialty Chemicals 15101050
> 15 Materials Materials Construction Materials Construction
> Materials 15102010
> Containers & Packaging Metal & Glass Containers 15103010
> Paper Packaging 15103020
> 15 Materials Materials Metals & Mining
> Aluminum 15104010
> Diversified Metals & Mining 15104020
> Gold 15104030
> Precious Metals & Minerals 15104040
> Steel 15104050
> 15 Materials Materials Paper & Forest Products Forest
> Products 15105010
> Paper Products 15105020
>
>
> can anyone tell me how 2 query for above
That's just presentational stuff. It is called "banding" in reports and
even the most basic reporting tool will do it for you. There isn't much
cause to do it in SQL and although it is certainly possible it will be
needlessly complex to do and won't perform well.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Navigation:
[Reply to this message]
|