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 abovehi,
The output format needed for you is not that clear. Still feels like you
need a groupby, like
10 Energy Energy Energy
10 Energy Energy Oil & Gas
15 Materials Materials Chemicals
15 Materials Materials Construction Materials
...........................
...........................
In this case you need to try a group by,
SELECT 1,2,3,SUM(ANY VALUE FEILD) FROM TABLE
GROUP BY 1,2,3
Not sure if this is what you what, if not give more details like tbale
structure and optut you needed in good format...
Thanks,
Sree
"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
>|||Best bet is to place your output on a web page and link to it from here.
Newsgroup posters/readers dont handle long lines/ line breaks very well, so
anything longer than 70 or 80 characters becomes an unreadable mess.
Also, post your table DDL, and try to explain what you want with words, in
addition to visuals.
"Sreejith G" <SreejithG@.discussions.microsoft.com> wrote in message
news:E492AFA1-A434-4101-A4D3-F7FB71E03EBA@.microsoft.com...
> hi,
> The output format needed for you is not that clear. Still feels like you
> need a groupby, like
> 10 Energy Energy Energy
> 10 Energy Energy Oil & Gas
> 15 Materials Materials Chemicals
> 15 Materials Materials Construction Materials
> ...........................
> ...........................
> In this case you need to try a group by,
> SELECT 1,2,3,SUM(ANY VALUE FEILD) FROM TABLE
> GROUP BY 1,2,3
> Not sure if this is what you what, if not give more details like tbale
> structure and optut you needed in good format...
> Thanks,
> Sree
>
>
>
> "kalikoi@.gmail.com" wrote:
>|||I got four table structures as follows
CREATE TABLE [dbo].[Sector] (
[SectorID] [int] NOT NULL ,
[SectorName] [varchar] (50)
)
the data is as follows
--
10 Energy
CREATE TABLE [dbo].[GroupMaster] (
[SectorID] [int] NOT NULL ,
[GroupID] [int] NOT NULL ,
[GroupName] [varchar] (50)
)
the data is as follows
--
10 1010 Energy
CREATE TABLE [dbo].[IndustryMaster] (
[GroupID] [int] NOT NULL ,
[IndustryID] [numeric](6, 0) NOT NULL ,
[IndustryName] [varchar] (50)
)
the data is as follows
---
1010 101010 Energy Equipment & Services
1010 101020 Oil & Gas
CREATE TABLE [dbo].[SubIndustryMaster] (
[IndustryID] [numeric](6, 0) NOT NULL ,
[SubIndustryID] [numeric](8, 0) NOT NULL ,
[SubIndustryName] [varchar] (30)
)
the data is as follows
----
101010 10101010 Oil & Gas Drilling
101010 10101020 Oil & Gas Equipment & Svcs
101020 10102010 Integrated Oil & Gas
101020 10102020 Oil & Gas Exploration & Prod
101020 10102030 Oil & Gas Refining & Mktg
101020 10102040 Oil & Gas Storage & Transpor
101020 10102050 Coal & Consumable Fuels
Now i want a ADO DataShape command which results the following
Energy
Energy
Energy Equipment & Services
Oil & Gas Drilling
Oil & Gas Equipment & Svcs
Oil & Gas
Integrated Oil & Gas
Oil & Gas Exploration & Prod
Oil & Gas Refining & Mktg
Oil & Gas Storage & Transpor
Coal & Consumable Fuels
No comments:
Post a Comment