Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Grouping all in one row

$
0
0

Hi guys, I got a black out. I got this situation:

Create table Forum ( Icity varchar(50), IMonth int, Iyear int, ACons int, BCons int, CCons int) insert into forum values ('Buenos Aires',1,2014,100,0,0), ('Buenos Aires',2,2014,140,0,0), ('Buenos Aires',3,2014,60,0,0), ('Toronto',1,2014,400,0,0), ('Toronto',2,2014,625,0,0), ('Toronto',3,2014,880,0,0), ('Buenos Aires',1,2014,0,330,0), ('Buenos Aires',2,2014,0,1230,0), ('Buenos Aires',3,2014,0,470,0), ('Toronto',1,2014,0,1100,0), ('Toronto',2,2014,0,1520,0), ('Toronto',3,2014,0,400,0), ('Buenos Aires',1,2014,0,0,300),('Buenos Aires',2,2014,0,0,440), ('Buenos Aires',3,2014,0,0,1080), ('Toronto',1,2014,0,0,640), ('Toronto',2,2014,0,0,1020), ('Toronto',3,2014,0,0,880)

I had to run a huge union all taking data fro ACons, BCons, CCons, no way to do link or other stuff, we're talking about millions rows, different servers..anyway. I got this situation. Now I need an output like:

Buenos Aires 1 2014 100 330 300

Toronto  1 2014  400 1100 640

Pratically Icity, Imonth, Iyear, Acons, Bcons, Ccons in one rows and not in three difefrent rows. I already did this stuff a lot of time but I'm going underpressure by another side ( a Cube that doesn't update correctly).

Any suggestion? Thanks everyone.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>