Solved

SQL Merge Rows

Posted on 2013-11-26
1
227 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:mcazabonnet
1 Comment
 
LVL 4

Accepted Solution

by:
mcazabonnet 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TSQL DateADD update Question 4 39
How can i make performance tuning to my sql query? 6 47
sql help 8 55
sql 2008 how to table join 2 15
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is 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 hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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