| Author |
Topic |
|
Code128
Starting Member
3 Posts |
Posted - 2011-10-13 : 04:00:38
|
| I’m trying to use a SQL string to filter some data. The original data is like this:Part_Number,Description,Crate_ID68015000221,MTM800E QUICK START GUIDE - AR,A1006804113J25,SAFETY LEAFLET-TETRA MOBILE,A1006864117B25,SAFETY LEAFLET - EMEA,A1006866534D68,R&TTE LEAFTLET MTM700,A100GKN6274A,PWR CBL 3086026B02 10A FUSE,A100GLN7324A,ARI LO PROFILE TRUNNION KIT,A100GMBN1021A,ACCESSORY CONNECTION KIT,A100GMSN4078B,SMALL SPEAKER 5W,A100GMWN4301B,NG CONTROL HEAD ARABIC,A100PMUE4465C,MTM800 ENH 380-430 TEA1,A100RMN5107B,COMPACT MOBILE MIC,A10068015000221,MTM800E QUICK START GUIDE - AR,A1006804113J25,SAFETY LEAFLET-TETRA MOBILE,A1006864117B25,SAFETY LEAFLET - EMEA,A1006866534D68,R&TTE LEAFTLET MTM700,A100GKN6274A,PWR CBL 3086026B02 10A FUSE,A100GLN7324A,ARI LO PROFILE TRUNNION KIT,A100GMBN1021A,ACCESSORY CONNECTION KIT,A100GMSN4078B,SMALL SPEAKER 5W,A100GMWN4301B,NG CONTROL HEAD ARABIC,A100PMUE4465C,MTM800 ENH 380-430 TEA1,A100RMN5107B,COMPACT MOBILE MIC,A10068015000221,MTM800E QUICK START GUIDE - AR,A1016804113J25,SAFETY LEAFLET-TETRA MOBILE,A1016864117B25,SAFETY LEAFLET - EMEA,A1016866534D68,R&TTE LEAFTLET MTM700,A101GKN6266A,PWR CBL DC BASE RENA,A101GLN7318A,BASE TRAY W/O SPKR ARIANE,A101GMBN1021A,ACCESSORY CONNECTION KIT,A101GMSN4078B,SMALL SPEAKER 5W,A101GMWN4301B,NG CONTROL HEAD ARABIC,A101GPN6145B,MOBILE RADIO PSU 138W,A101NTN7374AR,220V CHGR LINE CORD,A101PMUE4465C,MTM800 ENH 380-430 TEA1,A101RMN5106A,DESKTOP MIC,A101I would like to filter the distinct records based on Part Number, Description and crate ID and also count the number of duplicate records to give me the quantity of part numbers that are the same. This would give a summary table looking like below. This now tells me how many part number items are in each crate ID.Part_Number,Description,Crate_ID,qty68015000221,MTM800E QUICK START GUIDE - AR,A100,268015000221,MTM800E QUICK START GUIDE - AR,A101,16804113J25,SAFETY LEAFLET-TETRA MOBILE,A100,26804113J25,SAFETY LEAFLET-TETRA MOBILE,A101,16864117B25,SAFETY LEAFLET - EMEA,A100,26864117B25,SAFETY LEAFLET - EMEA,A101,16866534D68,R&TTE LEAFTLET MTM700,A100,26866534D68,R&TTE LEAFTLET MTM700,A101,1etc……The SQL query “SELECT DISTINCT part_number, description, crate_id from inventory”gets me close and “SELECT part_number, COUNT(part_number) as qty from inventory group by part_number” gives me the quantity figure I need. I become stuck trying to join these together to make one query and one table of results. Any thoughts? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-10-13 : 04:18:11
|
SELECT part_number, description, crate_id,COUNT(*) as qty from inventorygroup by part_number, description, crate_id No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Code128
Starting Member
3 Posts |
Posted - 2011-10-13 : 04:49:56
|
| Yeah that's great and works for me!Thanks for the super quick response Webfred! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-10-13 : 05:42:07
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|