Solved

SQL Merge Rows

Posted on 2013-11-26
1
238 Views
Last Modified: 2013-11-26
Hello,
How can merge this table?

region  osType  MyPC    Cap
EMEA    Mac     NULL    1006
EMEA    Vista   NULL    811
EMEA    Vista   28      NULL
EMEA    Win2k   NULL    1
EMEA    Win7    NULL    3957
EMEA    Win7    177     NULL
EMEA    Win8    NULL    625
EMEA    Win8    16      NULL
EMEA    Win8.1  NULL    173
EMEA    Win8.1  15      NULL
EMEA    XP      NULL    981
EMEA    XP      30      NULL
NA      Mac     NULL    8493
NA      Vista   NULL    5965
NA      Vista   135     NULL
NA      Win2k   NULL    19
NA      Win7    NULL    32636
NA      Win7    631     NULL
NA      Win8    NULL    7790
NA      Win8    154     NULL
NA      Win8.1  NULL    1073
NA      Win8.1  33      NULL
NA      XP      NULL    8118
NA      XP      136     NULL
 
Need it to look like this

region  osType  MyPC    Cap
EMEA    Mac     NULL    1006
EMEA    Vista   28    811
EMEA    Win2k   NULL    1
EMEA    Win7         177    3957
EMEA    Win8    16    625
EMEA    Win8.1  15    173
EMEA    XP      30    981
NA      Mac     NULL    8493
NA      Vista   135    5965
NA      Win2k   NULL    19
NA      Win7    631   32636
NA      Win8    154    7790
NA      Win8.1  33    1073
NA      XP      136    8118

Here's my work in progress

Select * from
(select s1.region, s1.osType, s1.MyPC, s1.Cap
from @tmpTable0 as s1
inner join @tmpTable0 as s2
on s1.region = s2.region and s1.osType = s2.osType) t where t.myPC is not null and t.Cap is not null
0
Comment
Question by:Mauro Cazabonnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
Mauro Cazabonnet earned 0 total points
ID: 39677845
I got it

Select * from
(select s1.region, s1.osType, s1.MyPC, s2.Cap
from @tmpTable0 as s1
inner join @tmpTable0 as s2
on s1.region = s2.region and s1.osType = s2.osType) t where t.myPC is not null and t.Cap is not null
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question