Group (string) Data

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
691
Office Version
  1. 2007
Platform
  1. Windows
Hi all,

"<html>
<head><style>.intestazioni {font-family : Arial;font-size : 10pt;color : black;text-align : center;font-weight : normal;background : #EBE7D4;}.celle {font-family : Times New Roman;font-size : 10pt;color : black;text-align : center;font-weight : normal;background: white;}</style></head>
<body>
<table bgcolor=#C0C0C0 cellspacing=1 width=80% align=center>
<tr class=intestazioni><td width=22>&nbsp</td><td>A</td><td>B</td><td>C</td><td>D</td></tr>
<tr><td class=intestazioni>1</td><td class=celle>Into a table I have this data:</td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
<tr><td class=intestazioni>2</td><td class=celle></td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
<tr><td class=intestazioni>3</td><td class=celle>NCR_BOL</td><td class=celle>NCR_PGR</td><td class=celle>NCR_PGRN</td><td class=celle>NCR_DESCR</td></tr>
<tr><td class=intestazioni>4</td><td class=celle>1376</td><td class=celle>100</td><td class=celle>1</td><td class=celle>20-1314-1309-1302-1268-1319-13</td></tr>
<tr><td class=intestazioni>5</td><td class=celle>1376</td><td class=celle>100</td><td class=celle>2</td><td class=celle>12</td></tr>
<tr><td class=intestazioni>6</td><td class=celle>1376</td><td class=celle>200</td><td class=celle>1</td><td class=celle>296-1269-1328-1297-1300</td></tr>
<tr><td class=intestazioni>7</td><td class=celle>1387</td><td class=celle>20</td><td class=celle>1</td><td class=celle>1266-1265</td></tr>
<tr><td class=intestazioni>8</td><td class=celle>1398</td><td class=celle>20</td><td class=celle>1</td><td class=celle>327</td></tr>
<tr><td class=intestazioni>9</td><td class=celle>1441</td><td class=celle>20</td><td class=celle>1</td><td class=celle>5-1315-1296-1309-1314-1300-126</td></tr>
<tr><td class=intestazioni>10</td><td class=celle>1441</td><td class=celle>20</td><td class=celle>2</td><td class=celle>9-1263-1262-1302-1297-1299-132</td></tr>
<tr><td class=intestazioni>11</td><td class=celle>1441</td><td class=celle>20</td><td class=celle>3</td><td class=celle>9-1301-1319-1308-1259</td></tr>
<tr><td class=intestazioni>12</td><td class=celle></td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
<tr><td class=intestazioni>13</td><td class=celle>I 'd like get this new table</td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
<tr><td class=intestazioni>14</td><td class=celle></td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
<tr><td class=intestazioni>15</td><td class=celle>NCR_BOL</td><td class=celle>NCR_PGR</td><td class=celle>NCR_PGRN</td><td class=celle>NCR_DESCR</td></tr>
<tr><td class=intestazioni>16</td><td class=celle>1376</td><td class=celle>100</td><td class=celle></td><td class=celle>20-1314-1309-1302-1268-1319-1312</td></tr>
<tr><td class=intestazioni>17</td><td class=celle>1376</td><td class=celle>200</td><td class=celle></td><td class=celle>296-1269-1328-1297-1300</td></tr>
<tr><td class=intestazioni>18</td><td class=celle>1387</td><td class=celle>20</td><td class=celle></td><td class=celle>1266-1265</td></tr>
<tr><td class=intestazioni>19</td><td class=celle>1398</td><td class=celle>20</td><td class=celle></td><td class=celle>327</td></tr>
<tr><td class=intestazioni>20</td><td class=celle>1441</td><td class=celle>20</td><td class=celle></td><td class=celle>5-1315-1296-1309-1314-1300-1269-1263-1262-1302-1297-1299-1329-1301-1319-1308-1259</td></tr>
<tr><td class=intestazioni>21</td><td class=celle></td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
<tr><td class=intestazioni>22</td><td class=celle>How can I get this? Tia.</td><td class=celle></td><td class=celle></td><td class=celle></td></tr>
</table>
</body></html>"
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi.

Not very clear what you want help with, however, after studying it for a while I think I see what you're after.

I think you want to group by NCR_BOL and NCR_PGR, but, when you find a row where both NCR_BOL and NCR_PGR are the same you want to add the differences in NCR_DESCR together in the one column.

If this is correct I'm not sure you can do it directly in SQL but you'd need to break out into VB. The way I'd tackle it would be to;

select * from table order by NCR_BOL, NCR_PGR

Then use a loop to scan through the records, adding together NCR_DESR where NCR_BOL and NCR_PGR are the same, when ever NCR_PGR or NCR_BOL changes I'd write the "new row" out to your new table.

Hope this helps

Chris
 
Upvote 0

Forum statistics

Threads
1,221,668
Messages
6,161,158
Members
451,687
Latest member
KENNETH ROGERS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top