dbTalk Databases Forums  

need help on sql query

comp.database.oracle comp.database.oracle


Discuss need help on sql query in the comp.database.oracle forum.



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

Default need help on sql query - 05-28-2005 , 03:13 PM






select region, issue, decode(value,'y','yes','n','no','--unknown--'),count
(value) val_count,
from data
group by
region, issue, decode(value,'y','yes','n','no','--unknown--'),count(value)

Reply With Quote
  #2  
Old   
Jasper Scholten
 
Posts: n/a

Default Re: need help on sql query - 05-28-2005 , 03:19 PM






Dizzler,

I do not see a question but remove the count(value) from your group by.

Cheers,

Jahudi

Dizzler wrote:

Quote:
select region, issue, decode(value,'y','yes','n','no','--unknown--'),count
(value) val_count,
from data
group by
region, issue, decode(value,'y','yes','n','no','--unknown--'),count(value)


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

Default Re: need help on sql query - 05-30-2005 , 02:16 AM



The question I replied to is below....

hi,
I have a following table data-

city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n

This table has value for each issue in every city.
How can I create a report from this which looks like-

region issue count(yes)
north i1 2
north i2 1
south i1 1
south i2 0
east i1 0
east i2 0


Please help/ideas for sql query

"Jasper Scholten" <jasc27054 (AT) yahoo (DOT) co.uk> wrote

Quote:
Dizzler,

I do not see a question but remove the count(value) from your group by.

Cheers,

Jahudi

Dizzler wrote:

select region, issue,
decode(value,'y','yes','n','no','--unknown--'),count
(value) val_count,
from data
group by
region, issue,
decode(value,'y','yes','n','no','--unknown--'),count(value)




Reply With Quote
  #4  
Old   
Jasper Scholten
 
Posts: n/a

Default Re: need help on sql query - 06-02-2005 , 03:30 PM



Dizzler,

Have you tried something yourself? I mean, this looks quite basic to me:

select region, issue, count(*)
from example
where value = 'Y'
group by region, issue
/


There are many other ways but this works like your example.

What did you try until now?

Regards,

Jahudi


Dizzler wrote:

Quote:
The question I replied to is below....

hi,
I have a following table data-

city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n

This table has value for each issue in every city.
How can I create a report from this which looks like-

region issue count(yes)
north i1 2
north i2 1
south i1 1
south i2 0
east i1 0
east i2 0


Please help/ideas for sql query

"Jasper Scholten" <jasc27054 (AT) yahoo (DOT) co.uk> wrote in message
news:euCdnavcnIjVTwXfRVnyiQ (AT) casema (DOT) nl...
Dizzler,

I do not see a question but remove the count(value) from your group by.

Cheers,

Jahudi

Dizzler wrote:

select region, issue,
decode(value,'y','yes','n','no','--unknown--'),count
(value) val_count,
from data
group by
region, issue,
decode(value,'y','yes','n','no','--unknown--'),count(value)





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.