Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Nathon Jones #1
help with GROUP BY clause?
Hi,
In my events table (Access DB), I have a field called "eventdate" which is
in short date format.
I have created a Recordset in DW in which I do the following:
SELECT eventdate
FROM qryEvents GROUP BY eventdate
Now, this shows the dates in order, and they are grouped correctly.
However, when I create a dynamic hyperlink from this to a results page
(showing Events that occur on the selected date), it is working for all of
the March dates, but only 2 or 3 of the April dates!! It seems completely
random.
What makes it more confusing is that the Group By clause is picking dates
from the Events query table (qryEvents), which only lists events that are
actually happening.
So why would March work, but not April!
Perplexed and starting to become dis-illusioned with computers.
Nath.
Nathon Jones Guest
-
#40218 [NEW]: Add Else clause to while
From: jbailey at raspberryginger dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug... -
May 29 Sydney Developers Group study group
On Monday 29th May, we'll be studying Actionscript 3. Please read the articles prior to the meeting (see <a target=_blank... -
Using IN in a WHERE clause
I'm trying to use IN in a WHERE clause as follows: idx_res.city IN ('#session.s_city#') The value of session.s_city is 'highlands ranch, lone... -
CF MX 6 WHERE Clause
Hi everyone! I keep getting the following error when I submit an update form for processing Macromedia] Too few parameters. Expected 1. The error... -
where clause with date (asp.net - vb)
Hi, I try to execute request on a ms-access database but I have a problem with date. the "myDate" field's format is "date/time" my request is:... -
RichMcCrea #2
Re: help with GROUP BY clause?
this may be similar to a problem I had with order by datefield against a SQL
server database. My query was very much like yours select * from mytable
order by somedate the query correctly ordered the data in query analyzer but
when ran in an ASP.NET (C#) environment, it sorted dates like strings (sorting
1/1/2004, then 11/1/2004, 12/1/2004 and then 2/1/2004). Never figured out why
but the fix was using datepart(yy, mytable.somedate) ,datepart(m,
mytable.somedate) ,datepart(d, mytable.somedate) try pulling the date apart
by year, month and day in your query's group by and see if you get the correct
behavior. Hope this helps.
RichMcCrea Guest
-
middletree #3
Re: help with GROUP BY clause?
I'm not sure why you even need the GROUP BY with that statement.
"Nathon Jones" <nathonjonesNOT@kirkmoor.com> wrote in message
news:cvl5ma$9h9$1@forums.macromedia.com...> Hi,
>
> In my events table (Access DB), I have a field called "eventdate" which is
> in short date format.
>
> I have created a Recordset in DW in which I do the following:
>
> SELECT eventdate
> FROM qryEvents GROUP BY eventdate
>
> Now, this shows the dates in order, and they are grouped correctly.
> However, when I create a dynamic hyperlink from this to a results page
> (showing Events that occur on the selected date), it is working for all of
> the March dates, but only 2 or 3 of the April dates!! It seems completely
> random.
>
> What makes it more confusing is that the Group By clause is picking dates
> from the Events query table (qryEvents), which only lists events that are
> actually happening.
>
> So why would March work, but not April!
>
> Perplexed and starting to become dis-illusioned with computers.
> Nath.
>
>
>
middletree Guest
-
Nathon Jones #4
Re: help with GROUP BY clause?
Hi,
Because several events appear on the same date, and I wanted to have a menu
that offered visitors the chance to select a date from a menu, or a list of
dates as links.
I therefore want to group the dates, so that the user only sees one of each
date, in order to make a selection.
I'm still stuggling with it.
Nath.
"middletree" <middletree@htomail.com> wrote in message
news:cvlcsc$kov$1@forums.macromedia.com...> I'm not sure why you even need the GROUP BY with that statement.
>
>
> "Nathon Jones" <nathonjonesNOT@kirkmoor.com> wrote in message
> news:cvl5ma$9h9$1@forums.macromedia.com...>>> Hi,
>>
>> In my events table (Access DB), I have a field called "eventdate" which
>> is
>> in short date format.
>>
>> I have created a Recordset in DW in which I do the following:
>>
>> SELECT eventdate
>> FROM qryEvents GROUP BY eventdate
>>
>> Now, this shows the dates in order, and they are grouped correctly.
>> However, when I create a dynamic hyperlink from this to a results page
>> (showing Events that occur on the selected date), it is working for all
>> of
>> the March dates, but only 2 or 3 of the April dates!! It seems
>> completely
>> random.
>>
>> What makes it more confusing is that the Group By clause is picking dates
>> from the Events query table (qryEvents), which only lists events that are
>> actually happening.
>>
>> So why would March work, but not April!
>>
>> Perplexed and starting to become dis-illusioned with computers.
>> Nath.
>>
>>
>>
>
Nathon Jones Guest
-
middletree #5
Re: help with GROUP BY clause?
That's not what GROUP BY is for. If you want to order by date, then use the
ORDER BY clause. If you want to only have one of each date, when there are
multiple rows returned, then use DISTINCT, and it will only return one row
per date.
middletree Guest
-
Nathon Jones #6
Re: help with GROUP BY clause?
Hi,
I see. So does that become:
SELECT eventdate
FROM qryEvents DISTINCT eventdate
Thanks.
Nath.
"middletree" <middletree@htomail.com> wrote in message
news:cvle0n$me9$1@forums.macromedia.com...> That's not what GROUP BY is for. If you want to order by date, then use
> the
> ORDER BY clause. If you want to only have one of each date, when there
> are
> multiple rows returned, then use DISTINCT, and it will only return one row
> per date.
>
>
Nathon Jones Guest
-
CMBergin #7
Re: help with GROUP BY clause?
SELECT DISTINCT blah blah
Now, go visit:
[url]www.sqlcourse.com[/url]
[url]www.sqlcourse2.com[/url]
"Nathon Jones" <nathonjonesNOT@kirkmoor.com> wrote in message
news:cvlen9$nfa$1@forums.macromedia.com...row> Hi,
>
> I see. So does that become:
>
> SELECT eventdate
> FROM qryEvents DISTINCT eventdate
>
> Thanks.
> Nath.
>
> "middletree" <middletree@htomail.com> wrote in message
> news:cvle0n$me9$1@forums.macromedia.com...> > That's not what GROUP BY is for. If you want to order by date, then use
> > the
> > ORDER BY clause. If you want to only have one of each date, when there
> > are
> > multiple rows returned, then use DISTINCT, and it will only return one>> > per date.
> >
> >
>
CMBergin Guest
-
middletree #8
Re: help with GROUP BY clause?
What CMBergin says is correct. GROUP BY only comes into play if you're doing
math with one of the fields you are selecting.
Here's an example:
=======
SELECT T.TKT_TICKETID, MAX(H.TIMESTMP)AS HistTime
FROM dbo.TKT_TICKET T
WHERE T.StatusID = '"&strStatus&"' "
GROUP BY T.TKT_TICKETID
ORDER BY " & strSort & ""
=======
Note that I have a couple of variables in there, that start with str*.
Ignore that. Point is, the MAX I have on that one field means that I want
the date with the highest value (the latest date). Since MAX is considered a
math function, I have to tell the query to do a GROUP BY for all the other
fields. In this simple example, there only happens to be one other field.
"Nathon Jones" <nathonjonesNOT@kirkmoor.com> wrote in message
news:cvlen9$nfa$1@forums.macromedia.com...row> Hi,
>
> I see. So does that become:
>
> SELECT eventdate
> FROM qryEvents DISTINCT eventdate
>
> Thanks.
> Nath.
>
> "middletree" <middletree@htomail.com> wrote in message
> news:cvle0n$me9$1@forums.macromedia.com...> > That's not what GROUP BY is for. If you want to order by date, then use
> > the
> > ORDER BY clause. If you want to only have one of each date, when there
> > are
> > multiple rows returned, then use DISTINCT, and it will only return one>> > per date.
> >
> >
>
middletree Guest
-
CMBergin #9
Re: help with GROUP BY clause?
Well, there is one other situation in which you'd use group by: when you
want to filter based on a group instead of individual records. For
instance, if you wanted all dates that had more than 1 event, you'd use
GROUP BY and HAVING to get the right results.
"middletree" <middletree@htomail.com> wrote in message
news:cvlj27$h2$1@forums.macromedia.com...doing> What CMBergin says is correct. GROUP BY only comes into play if you'rea> math with one of the fields you are selecting.
>
>
> Here's an example:
>
> =======
> SELECT T.TKT_TICKETID, MAX(H.TIMESTMP)AS HistTime
> FROM dbo.TKT_TICKET T
> WHERE T.StatusID = '"&strStatus&"' "
> GROUP BY T.TKT_TICKETID
> ORDER BY " & strSort & ""
> =======
>
> Note that I have a couple of variables in there, that start with str*.
> Ignore that. Point is, the MAX I have on that one field means that I want
> the date with the highest value (the latest date). Since MAX is considereduse> math function, I have to tell the query to do a GROUP BY for all the other
> fields. In this simple example, there only happens to be one other field.
>
>
>
>
>
> "Nathon Jones" <nathonjonesNOT@kirkmoor.com> wrote in message
> news:cvlen9$nfa$1@forums.macromedia.com...> > Hi,
> >
> > I see. So does that become:
> >
> > SELECT eventdate
> > FROM qryEvents DISTINCT eventdate
> >
> > Thanks.
> > Nath.
> >
> > "middletree" <middletree@htomail.com> wrote in message
> > news:cvle0n$me9$1@forums.macromedia.com...> > > That's not what GROUP BY is for. If you want to order by date, thenthere> > > the
> > > ORDER BY clause. If you want to only have one of each date, when> row> > > are
> > > multiple rows returned, then use DISTINCT, and it will only return one>> >> > > per date.
> > >
> > >
> >
>
CMBergin Guest
-
middletree #10
Re: help with GROUP BY clause?
Good point.
Of course, Nathon's situation still doesn't call for GROUP BY
middletree Guest
-
CMBergin #11
Re: help with GROUP BY clause?
Nope.
I wonder if some database books teach GROUP BY as a method for getting
distinct records, though, because there have been a lot of people on the
forum that do that. Oh, well.
"middletree" <middletree@htomail.com> wrote in message
news:cvnahk$ffu$1@forums.macromedia.com...> Good point.
>
> Of course, Nathon's situation still doesn't call for GROUP BY
>
>
CMBergin Guest



Reply With Quote

