Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Merge Rows

Posted on 2013-11-26
1
Medium Priority
?
248 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
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

972 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