Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 4th, 2008, 07:54 AM
Member
 
Join Date: Jul 2008
Location: Malaysia
Age: 23
Posts: 37
Default Can anyone help with merge sql statement.

Hi there,

Im trying to do a table view with each of the statement will give output in each column. but i dono how to combine this two statement to become one sql statement. Please help me.

Code:
RESOLVED
select Ticowner, count(TicStatus)as "resolved"
From Ticket
where Ticstatus = 'resolved'
Group by Ticowner


UNRESOLVED
select Ticowner, count(TicStatus)as "UNresolved"
From Ticket
where Ticstatus <> 'resolved'
Group by Ticowner
Regards,
Meshack
Reply
  #2  
Old September 4th, 2008, 10:43 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,298
Default

Will UNION help?
Reply
  #3  
Old September 5th, 2008, 01:52 AM
Member
 
Join Date: Jul 2008
Location: Malaysia
Age: 23
Posts: 37
Default

hi r035198x,

Quote:
Originally Posted by r035198x
Will UNION help?
thanks for reply...
union can merge but not as i want....
if i use union, it will look like this...

Code:
select Ticowner, count(TicStatus)as "resolved"
From Ticket
where Ticstatus = 'resolved'
Group by Ticowner
Union
select Ticowner, count(TicStatus)as "UNresolved"
From Ticket
where Ticstatus <> 'resolved'
Group by Ticowner
Ticowner | resolved
LB | 2
LB | 3
MEA | 1
MEA | 3
RAS | 2
RAS | 7

i want something looksn like this....

Ticowner | resolved | unresolved
LB | 2 | 3
MEA | 3 | 1
RAS | 7 | 2

Can help me ah? I have no idea how to do it.... Im just know the basic only....
thanks again.

- Meshack
Reply
  #4  
Old September 5th, 2008, 07:54 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,298
Default

Try something like

Code:
select T.Ticowner,
(select count(tt.TicStatus)as "resolved"
From Ticket tt
where tt.Ticstatus = 'resolved'
and tt.Ticowner = T.Ticowner) as resolved,

(select count(tt.TicStatus)as "unresolved"
From Ticket tt
where tt.Ticstatus <> 'resolved'
and tt.Ticowner = T.Ticowner) as unresolved

from Tickect T
I haven't tested it though.
Reply
  #5  
Old September 5th, 2008, 08:10 AM
Member
 
Join Date: Jul 2008
Location: Malaysia
Age: 23
Posts: 37
Default

Hai r035198x,

Its working well... thank you very much...

-Meshack
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles