July 17, 2013 at 6:34 am
Hai friends,
i ve the table like below
create table student
(
class_atttend datetime,
name varchar(20)
)
insert into student values ('02-07-2013', 'A')
insert into student values ('03-07-2013', 'A')
insert into student values ('04-07-2013', 'A')
insert into student values ('05-07-2013', 'A')
insert into student values ('06-07-2013', 'A')
insert into student values ('07-07-2013', 'A')
insert into student values ('08-07-2013', 'A')
my required output is from the firstdate of where was appeared on it?
expecting output:
===========
02-07-2013
July 17, 2013 at 6:43 am
Homework assignment?
Just use a GROUP BY in combination with a MIN statement.
July 17, 2013 at 7:00 am
hai friend,
actually i ve two tables
like
create table student
(
attendence datetime,
name varchar(10),
student_id varchar(20)
)
insert into student values ('02-07-2013', 'A')
insert into student values ('03-07-2013', 'A')
insert into student values ('04-07-2013', 'A')
insert into student values ('05-07-2013', 'A')
insert into student values ('06-07-2013', 'A')
insert into student values ('07-07-2013', 'A')
insert into student values ('08-07-2013', 'A')
create table homework
(
attendence datetime,
subject varchar(20),
student_id varchar(20)
)
insert into student values ('02-07-2013', 'Maths')
insert into student values ('03-07-2013', 'Maths')
insert into student values ('04-07-2013', 'Maths')
insert into student values ('05-07-2013', 'Maths')
insert into student values ('06-07-2013', 'Maths')
insert into student values ('07-07-2013', 'Maths')
insert into student values ('08-07-2013', 'Maths')
so i made join query
select
min(a.attendence) as workdays,
b.subject
from
student a
inner join
homework b
on
a.student_id = b.student_id
group by
a.attendence,
b.subject
its showing output of
02-07-2013 maths
03-07-2013 maths
what is the problem...................
July 17, 2013 at 7:07 am
You have to remove column [attendence] from the GROUP BY because you are aggregating these values with the MIN statement.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply