dbTalk Databases Forums  

Developing Query

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Developing Query in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Don B
 
Posts: n/a

Default Developing Query - 05-19-2010 , 10:50 AM






select INQMSIS.mine_tbl.sic_desc, COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM), COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM) * 200000 from INQPROD.ACC_INJ_TBL,
INQMSIS.mine_tbl where ((INQMSIS.mine_tbl.c_m_ind = 'M') and
(INQPROD.ACC_INJ_TBL.INJ_DEGR_CD IN ('01', '02', '03', '04', '05',
'06')) and ((to_number(to_char(INQPROD.ACC_INJ_TBL.AI_DT,'YYY Y' ))) =
2009)) and INQPROD.ACC_INJ_TBL.MINE_ID = INQMSIS.mine_tbl.mine_id
group by INQMSIS.mine_tbl.sic_desc order by 1 ;

I am trying to modify a query to show an additional column. This
column is suppose to multiply the Count Document No. column by
200,000. I am a beginner and cannot figure out what I'm doing wrong.
Can somebody get me on the right path.

Thanks
Don

Reply With Quote
  #2  
Old   
Mark D Powell
 
Posts: n/a

Default Re: Developing Query - 05-21-2010 , 09:13 AM






On May 19, 11:50*am, Don B <Braenovich.... (AT) DOL (DOT) GOV> wrote:
Quote:
select INQMSIS.mine_tbl.sic_desc, COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM), COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM) * 200000 from INQPROD.ACC_INJ_TBL,
INQMSIS.mine_tbl where ((INQMSIS.mine_tbl.c_m_ind = 'M') and
(INQPROD.ACC_INJ_TBL.INJ_DEGR_CD IN ('01', '02', '03', '04', '05',
'06')) and ((to_number(to_char(INQPROD.ACC_INJ_TBL.AI_DT,'YYY Y' ))) =
2009)) and INQPROD.ACC_INJ_TBL.MINE_ID = INQMSIS.mine_tbl.mine_id
group by INQMSIS.mine_tbl.sic_desc order by 1 ;

I am trying to modify a query to show an additional column. *This
column is suppose to multiply the Count Document No. column by
200,000. *I am a beginner and cannot figure out what I'm doing wrong.
Can somebody get me on the right path.

Thanks
Don
It would be helpful if you would post the actual Oracle error message
you are receiving or at least explicitly state what issue you face.

Generally speaking when you use a group by clause every column in the
select list either has to be part of the group by clause or have an
aggregate function applied to it. If you try to reference individual
column values you get an error.

Perhaps you want sum(col * 200000) or 200000 * sum(col) but from your
post I cannot tell.

HTH -- Mark D Powell --

Reply With Quote
  #3  
Old   
Shakespeare
 
Posts: n/a

Default Re: Developing Query - 05-21-2010 , 10:02 AM



Op 21-5-2010 16:13, Mark D Powell schreef:
Quote:
On May 19, 11:50 am, Don B<Braenovich.... (AT) DOL (DOT) GOV> wrote:
select INQMSIS.mine_tbl.sic_desc, COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM), COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM) * 200000 from INQPROD.ACC_INJ_TBL,
INQMSIS.mine_tbl where ((INQMSIS.mine_tbl.c_m_ind = 'M') and
(INQPROD.ACC_INJ_TBL.INJ_DEGR_CD IN ('01', '02', '03', '04', '05',
'06')) and ((to_number(to_char(INQPROD.ACC_INJ_TBL.AI_DT,'YYY Y' ))) =
2009)) and INQPROD.ACC_INJ_TBL.MINE_ID = INQMSIS.mine_tbl.mine_id
group by INQMSIS.mine_tbl.sic_desc order by 1 ;

I am trying to modify a query to show an additional column. This
column is suppose to multiply the Count Document No. column by
200,000. I am a beginner and cannot figure out what I'm doing wrong.
Can somebody get me on the right path.

Thanks
Don

It would be helpful if you would post the actual Oracle error message
you are receiving or at least explicitly state what issue you face.

Generally speaking when you use a group by clause every column in the
select list either has to be part of the group by clause or have an
aggregate function applied to it. If you try to reference individual
column values you get an error.

Perhaps you want sum(col * 200000) or 200000 * sum(col) but from your
post I cannot tell.

What is the difference?

Quote:
HTH -- Mark D Powell --


Shakespeare

Reply With Quote
  #4  
Old   
Shakespeare
 
Posts: n/a

Default Re: Developing Query - 05-21-2010 , 10:06 AM



Op 19-5-2010 17:50, Don B schreef:
Quote:
select INQMSIS.mine_tbl.sic_desc, COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM), COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM) * 200000 from INQPROD.ACC_INJ_TBL,
INQMSIS.mine_tbl where ((INQMSIS.mine_tbl.c_m_ind = 'M') and
(INQPROD.ACC_INJ_TBL.INJ_DEGR_CD IN ('01', '02', '03', '04', '05',
'06')) and ((to_number(to_char(INQPROD.ACC_INJ_TBL.AI_DT,'YYY Y' ))) =
2009)) and INQPROD.ACC_INJ_TBL.MINE_ID = INQMSIS.mine_tbl.mine_id
group by INQMSIS.mine_tbl.sic_desc order by 1 ;

Try something like this:




select sic_desc, mycount, 200000 * mycount myproduct from (
select INQMSIS.mine_tbl.sic_desc, COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM) mycount from INQPROD.ACC_INJ_TBL,
INQMSIS.mine_tbl where ((INQMSIS.mine_tbl.c_m_ind = 'M') and
(INQPROD.ACC_INJ_TBL.INJ_DEGR_CD IN ('01', '02', '03', '04', '05',
'06')) and ((to_number(to_char(INQPROD.ACC_INJ_TBL.AI_DT,'YYY Y' ))) =
2009)) and INQPROD.ACC_INJ_TBL.MINE_ID = INQMSIS.mine_tbl.mine_id
group by INQMSIS.mine_tbl.sic_desc) order by 1 ;


Shakespeare

Reply With Quote
  #5  
Old   
joel garry
 
Posts: n/a

Default Re: Developing Query - 05-21-2010 , 11:11 AM



On May 21, 8:02*am, Shakespeare <what... (AT) xs4all (DOT) nl> wrote:
Quote:
Op 21-5-2010 16:13, Mark D Powell schreef:



On May 19, 11:50 am, Don B<Braenovich.... (AT) DOL (DOT) GOV> *wrote:
select INQMSIS.mine_tbl.sic_desc, COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM), COUNT
(INQPROD.ACC_INJ_TBL.AI_DOC_NUM) * 200000 from INQPROD.ACC_INJ_TBL,
INQMSIS.mine_tbl where ((INQMSIS.mine_tbl.c_m_ind = 'M') and
(INQPROD.ACC_INJ_TBL.INJ_DEGR_CD IN ('01', '02', '03', '04', '05',
'06')) and ((to_number(to_char(INQPROD.ACC_INJ_TBL.AI_DT,'YYY Y' ))) =
2009)) and INQPROD.ACC_INJ_TBL.MINE_ID = INQMSIS.mine_tbl.mine_id
group by INQMSIS.mine_tbl.sic_desc order by 1 ;

I am trying to modify a query to show an additional column. *This
column is suppose to multiply the Count Document No. column by
200,000. *I am a beginner and cannot figure out what I'm doing wrong..
Can somebody get me on the right path.

Thanks
Don

It would be helpful if you would post the actual Oracle error message
you are receiving or at least explicitly state what issue you face.

Generally speaking when you use a group by clause every column in the
select list either has to be part of the group by clause or have an
aggregate function applied to it. *If you try to reference individual
column values you get an error.

Perhaps you want sum(col * 200000) or 200000 * sum(col) but from your
post I cannot tell.

What is the difference?

HTH -- Mark D Powell --

Shakespeare
It is possible to have rounding issues do funny things in sqlplus
formatting. It may also be possible to have rounding differences in
this type of sum and multiplication, depending on col values. Not
everything can go cleanly from decimal to binary, even with 38 digits
of precision.

jg
--
@home.com is bogus.
http://yro.slashdot.org/story/10/05/...To-Advertisers

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.