Hi Helpfuls
I am having difficulty working out how to group the results of a select into groups but those groups need to be ordered randomly.
So this is my query without grouping,
SELECT dbo.Machines.MachName, dbo.Machines.class, dbo.Machines.MachineID,
dbo.Companies.Name, dbo.Implimentation.Location, dbo.Machine_categories.CatName,
dbo.Machines.Units, dbo.Machines.CoolingPower, dbo.Machines.CatPrice, dbo.Machines.Reversable
FROM dbo.Machines INNER JOIN dbo.Companies ON
dbo.Machines.ManID = dbo.Companies.ManID
LEFT OUTER JOIN dbo.Implimentation ON
dbo.Machines.LocationID = dbo.Implimentation.LocationID
INNER JOIN dbo.Machine_categories ON
dbo.Machines.CategoryID = dbo.Machine_categories.CatID
Where dbo.Machines.CoolingPower between 2500 and 3499
What needs to happen is the results need to be grouped by dbo.Companies.Name (or dbo.Companies.ManID [which is the PK of dbo.Companies]) but each time the query is fired I want the groups in a different order, so that the Companies that manufacture these machines are not always in the same position in the list (they get upset when their competitior is always first in the list!!!)
Result of query as is
MSZ-FA25VA(H) A 41 [red]Mitsubishi[/red] Murale Mono Split 0 2500.0 670.0000 1
RAS-10NKV-E A 42 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 535.0000 1
MUZ-FA25VA A 45 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1020.0000 1
RAS-B10EKVP-E A 43 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 850.0000 1
MUZ-FA25VAH A 46 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1200.0000 1
Required result first time (random)
MSZ-FA25VA(H) A 41 [red]Mitsubishi[/red] Murale Mono Split 0 2500.0 670.0000 1
MUZ-FA25VA A 45 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1020.0000 1
MUZ-FA25VAH A 46 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1200.0000 1
RAS-10NKV-E A 42 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 535.0000 1
RAS-B10EKVP-E A 43 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 850.0000 1
Required result second time (random)
RAS-10NKV-E A 42 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 535.0000 1
RAS-B10EKVP-E A 43 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 850.0000 1
MSZ-FA25VA(H) A 41 [red]Mitsubishi[/red] Murale Mono Split 0 2500.0 670.0000 1
MUZ-FA25VA A 45 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1020.0000 1
MUZ-FA25VAH A 46 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1200.0000 1
what the problem is is the lack of my ability to be able to group the results by Companies.name. Once all the companies are grouped into all Toshiba's together and all Mitsubishi's together then I need to randomly order those groups
I could have ordered the query as is with
order by Companies.name
But they will only be grouped and ordered alphanumerically and therefore the same result each firing of the query, and as I said I need a different order of those groups each firing.
I really hope you can help me out here,
Many thanks
Andy
I am having difficulty working out how to group the results of a select into groups but those groups need to be ordered randomly.
So this is my query without grouping,
SELECT dbo.Machines.MachName, dbo.Machines.class, dbo.Machines.MachineID,
dbo.Companies.Name, dbo.Implimentation.Location, dbo.Machine_categories.CatName,
dbo.Machines.Units, dbo.Machines.CoolingPower, dbo.Machines.CatPrice, dbo.Machines.Reversable
FROM dbo.Machines INNER JOIN dbo.Companies ON
dbo.Machines.ManID = dbo.Companies.ManID
LEFT OUTER JOIN dbo.Implimentation ON
dbo.Machines.LocationID = dbo.Implimentation.LocationID
INNER JOIN dbo.Machine_categories ON
dbo.Machines.CategoryID = dbo.Machine_categories.CatID
Where dbo.Machines.CoolingPower between 2500 and 3499
What needs to happen is the results need to be grouped by dbo.Companies.Name (or dbo.Companies.ManID [which is the PK of dbo.Companies]) but each time the query is fired I want the groups in a different order, so that the Companies that manufacture these machines are not always in the same position in the list (they get upset when their competitior is always first in the list!!!)
Result of query as is
MSZ-FA25VA(H) A 41 [red]Mitsubishi[/red] Murale Mono Split 0 2500.0 670.0000 1
RAS-10NKV-E A 42 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 535.0000 1
MUZ-FA25VA A 45 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1020.0000 1
RAS-B10EKVP-E A 43 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 850.0000 1
MUZ-FA25VAH A 46 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1200.0000 1
Required result first time (random)
MSZ-FA25VA(H) A 41 [red]Mitsubishi[/red] Murale Mono Split 0 2500.0 670.0000 1
MUZ-FA25VA A 45 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1020.0000 1
MUZ-FA25VAH A 46 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1200.0000 1
RAS-10NKV-E A 42 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 535.0000 1
RAS-B10EKVP-E A 43 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 850.0000 1
Required result second time (random)
RAS-10NKV-E A 42 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 535.0000 1
RAS-B10EKVP-E A 43 [blue]Toshiba[/blue] Murale Mono Split 0 2500.0 850.0000 1
MSZ-FA25VA(H) A 41 [red]Mitsubishi[/red] Murale Mono Split 0 2500.0 670.0000 1
MUZ-FA25VA A 45 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1020.0000 1
MUZ-FA25VAH A 46 [red]Mitsubishi[/red] NULL Mono Split 1 2500.0 1200.0000 1
what the problem is is the lack of my ability to be able to group the results by Companies.name. Once all the companies are grouped into all Toshiba's together and all Mitsubishi's together then I need to randomly order those groups
I could have ordered the query as is with
order by Companies.name
But they will only be grouped and ordered alphanumerically and therefore the same result each firing of the query, and as I said I need a different order of those groups each firing.
I really hope you can help me out here,
Many thanks
Andy