|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
removing duplicates from inner joins
Hi There,
I was wondering if someone could help me with the results on this query, at the moment I am getting values repeated and I was wondering if it was possible to have some of the columns grouped, I have tried to have grouping at the end of the query but this still did not group the rows. Thanks in advance for your answer - Sean The structure that i'm trying to acheive is like the following: with each colour having multiple quantitys for each size: colourdesc| sizedesc | xs | s | m | l ----------- black |qoh| | 0 | 2 | 0 | 7 ----------- white |qoh| | 0 | 0 | 0 | 0 ----------- !-- query results +------------+------+------+-----------+--------+---------------+----------+ | qoh | size | shop | style | colour | colourdesc | sizedesc | +------------+------+------+-----------+--------+---------------+----------+ | 0000000007 | 6 | 1 | 10475RIB1 | 2 | BLACK | L | | 0000000000 | 6 | 1 | 10475RIB1 | 36 | CORRECTOR6771 | L | | 0000000000 | 6 | 1 | 10475RIB1 | 15 | SPEARMINT6581 | L | | 0000000000 | 6 | 1 | 10475RIB1 | 6 | WHITE | L | | 0000000007 | 5 | 1 | 10475RIB1 | 2 | BLACK | M | | 0000000000 | 5 | 1 | 10475RIB1 | 36 | CORRECTOR6771 | M | | 0000000000 | 5 | 1 | 10475RIB1 | 18 | MERINGUE4016 | M | | 0000000000 | 5 | 1 | 10475RIB1 | 6 | WHITE | M | | 0000000002 | 4 | 1 | 10475RIB1 | 2 | BLACK | S | +------------+------+------+-----------+--------+---------------+----------+ !--- query select qoh , shopsales.size, shopsales.shop, shopsales.style, shopsales.colour, co.colourdesc, sz.sizedesc from shopsales inner join shops on shopsales.shop = shops.shop inner join colours co on shopsales.style = co.style and shopsales.colour = co.colour inner join sizes sz on shopsales.style = sz.style and shopsales.size = sz.size where shopsales.shop = 1 and shopsales.style = '10475RIB1' |
|
#2
|
||||
|
||||
|
are you saying you want several rows "collapsed" so that they show multiple sizes on one line?
no, you must do that in your scripting language, add an ORDER BY so that you get the rows in the order you want by control fields, i.e. "grouped" by shop, style, whatever, with size last then loop over the rows, accumulating data in variables, and when you detect a break in the control fields, print a line |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > removing duplicates from inner joins |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|