473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

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.

Expand|Select|Wrap|Line Numbers
  1. RESOLVED
  2. select Ticowner, count(TicStatus)as "resolved"
  3. From Ticket
  4. where Ticstatus = 'resolved'
  5. Group by Ticowner
  6.  
  7.  
  8. UNRESOLVED
  9. select Ticowner, count(TicStatus)as "UNresolved"
  10. From Ticket
  11. where Ticstatus <> 'resolved'
  12. Group by Ticowner
Regards,
Meshack
Sep 4 '08 #1
4 1360
r035198x
13,262 8TB
Will UNION help?
Sep 4 '08 #2
hi r035198x,

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

Expand|Select|Wrap|Line Numbers
  1. select Ticowner, count(TicStatus)as "resolved"
  2. From Ticket
  3. where Ticstatus = 'resolved'
  4. Group by Ticowner
  5. Union
  6. select Ticowner, count(TicStatus)as "UNresolved"
  7. From Ticket
  8. where Ticstatus <> 'resolved'
  9. 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
Sep 5 '08 #3
r035198x
13,262 8TB
Try something like

Expand|Select|Wrap|Line Numbers
  1. select T.Ticowner,
  2. (select count(tt.TicStatus)as "resolved"
  3. From Ticket tt
  4. where tt.Ticstatus = 'resolved'
  5. and tt.Ticowner = T.Ticowner) as resolved,
  6.  
  7. (select count(tt.TicStatus)as "unresolved"
  8. From Ticket tt
  9. where tt.Ticstatus <> 'resolved'
  10. and tt.Ticowner = T.Ticowner) as unresolved
  11.  
  12. from Tickect T
I haven't tested it though.
Sep 5 '08 #4
Hai r035198x,

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

-Meshack
Sep 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Private Pyle | last post by:
Version 8.1 fixpack 5, AIX 5.1 32-bit I have a situation where I want to use a merge statement to perform insert else update logic to move data from one table to another. I have a working merge...
4
by: jbow0527 | last post by:
Here is what I have: Table1 with two key fields: PartNum and WH# (warehouse number) Table2 with only one key field: PartNum Both tables contain a field called Price. I want to update Table1...
1
by: Bob Stearns | last post by:
Does the following message get generated before or after the additional conditions given in the merge are evaluated? Error: The same row of target table "NULLID.AICA" was identified more than...
3
by: deko | last post by:
Problem: why doesn't this With block work? is it possible to have a For Each loop within a With block? With objWord .Documents.Add Template:=strTemplate, NewTemplate:=False, DocumentType:=0...
4
by: marklawford | last post by:
Hi guys, I'm getting the following error message when trying to run a MERGE statement I'm putting together. The syntax looks right to me But i must be missing something. The "srce" table...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
16
by: Sam Durai | last post by:
Hello, I need to merge a small table (of rows less than 100,sometimes even 0 rows) to a big table (of rows around 4 billion). I used the PK of the big table as merge key but merge does a table scan...
7
by: Michel Esber | last post by:
Question About Merge DB2 V8 LUW FP 15. Hello, Consider table A (ID integer not null PK, Field2 varchar(50)). I have the existing following set of rows in the table:
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
7
by: Henry J. | last post by:
I got a dumb question on the merge statement. I read the following example of merge statement at the IBM page:...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.