Re: Want to Order By a field not group by
From: M K (mark_at_nospamcenturycolor.com)
Date: 10/05/04
- Next message: John Cappelletti: "RE: Want to Order By a field not group by"
- Previous message: Scott Lyon: "Re: Trying to optimize a query with a bunch of INNER JOINs"
- In reply to: Tibor Karaszi: "Re: Want to Order By a field not group by"
- Next in thread: Toby Herring: "Re: Want to Order By a field not group by"
- Reply: Toby Herring: "Re: Want to Order By a field not group by"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 5 Oct 2004 09:49:05 -0700
Won't let me put an Order By unless I include that field in the Group By as
well. But I don't want to group by the IdentField.
"Tibor Karaszi" wrote:
> I still fail to see why you are talking about "order" and then have only GROUP BY in the query.
> GROUP BY does not guarantee a specific order in the result set. ORDER BY does.
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
>
> "Mal .mullerjannie@hotmail.com>" <<removethis> wrote in message
> news:8D3169FF-DBE4-4067-B407-425B78A2CB16@microsoft.com...
> > It's not that simple, you want to order by 2 values that was rolledup to 1,
> > I would do
> >
> > SELECT Field1, Field2, max(id) FROM Table1
> > GROUP BY Field1, Field2
> >
> > or use replace max(id) with another subselect that use results of the group
> > by.
> >
> > "M K" wrote:
> >
> >> Okay, simple example of my issue. I have a table like this:
> >>
> >> IdentField Field1 Field2 Field3
> >> 1 Yada Other B
> >> 2 Yada Other C
> >> 3 Anothe Other B
> >> 4 Anothe Other C
> >>
> >> I want to do a SELECT query that gives me
> >> Field1 Field2
> >> Yada Other
> >> Anothe Other
> >>
> >> So, I'd do:
> >> SELECT Field1, Field2 FROM Table1
> >> GROUP BY Field1, Field2
> >>
> >> However, I am getting:
> >> Field1 Field2
> >> Anothe Other
> >> Yada Other
> >>
> >> So my select query is sorting by Field1. I don't want it sorted by Field1 I
> >> want it in the order it is in Table1, sorted by IdentField. But I don't want
> >> it grouped by IdentField.
> >>
> >> Seems like a simple request, why can't I do it.
>
>
>
- Next message: John Cappelletti: "RE: Want to Order By a field not group by"
- Previous message: Scott Lyon: "Re: Trying to optimize a query with a bunch of INNER JOINs"
- In reply to: Tibor Karaszi: "Re: Want to Order By a field not group by"
- Next in thread: Toby Herring: "Re: Want to Order By a field not group by"
- Reply: Toby Herring: "Re: Want to Order By a field not group by"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|