Solved

sql server query grouping

Posted on 2014-03-12
5
109 Views
Last Modified: 2014-03-18
I have a query that is returning the following data.  

Broward County     07DB-3V-11-16-01-Z 08   596000531    Buyouts    Null          Null
Broward County     07DB-3V-11-16-01-Z 08   596000531    Null          Null          Buyouts

I would like to group it up to just show one line that looks like :

Broward County     07DB-3V-11-16-01-Z 08   596000531    Buyouts     Null     Buyouts

Thanks in advance.
0
Comment
Question by:Paulconsulting
  • 3
5 Comments
 
LVL 7

Expert Comment

by:Kishan Zunjare
Comment Utility
Here you can use Group By clause in SQL to combine result, you can apply group by on selected columns
0
 

Author Comment

by:Paulconsulting
Comment Utility
Grouping doesn't work for me in this scenario, at least not that I can tell.  Do you have a query in mind?
0
 

Accepted Solution

by:
Paulconsulting earned 0 total points
Comment Utility
I resolved it, I inserted the results into a Temp table then joined on itself.
0
 
LVL 69

Expert Comment

by:ScottPletcher
Comment Utility
SELECT name, id1, id2, MAX(buyout1) AS buyout1, MAX(buyout2) AS buyout2, MAX(buyout3)  AS buyout3
FROM ...
GROUP BY name, id1, id2


Corresponds to sample data like this:
name = Broward County
id1 = 07DB-3V-11-16-01-Z 08
id2 = 596000531
buyout1 = Buyouts
buyout2 = Null
buyout3 = Null
...
buyout1 = Null
buyout2 = Null
buyout3 = Buyouts
0
 

Author Closing Comment

by:Paulconsulting
Comment Utility
I resolved it, I inserted the results into a Temp table then joined on itself.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now