Home » SQL & PL/SQL » SQL & PL/SQL » how to write this sql query
how to write this sql query [message #324962] |
Wed, 04 June 2008 11:36 |
bztom33
Messages: 95 Registered: June 2005
|
Member |
|
|
Hi,
How can I query a unique list of users?
create table report(
user_id number,
first varchar2(20),
last varchar2(20),
report_date date,
actual_date date,
constraint report_pk primary key (user_id,report_date,actual_date);
insert into report(user_id,first,last,report_date,actual_date)
values(1,'Jane','Doe','01/01/2008','06/04/2008 09:36');
insert into report(user_id,first,last,report_date,actual_date)
values(1,'John','Doe','04/01/2008','06/04/2008 10:36');
insert into report(user_id,first,last,report_date,actual_date)
values(1,'Jane','Doe','06/01/2008','06/05/2008 11:36');
insert into report(user_id,first,last,report_date,actual_date)
values(1,'Jane','Doe','04/02/2008','06/07/2008 08:36');
insert into report(user_id,first,last,report_date,actual_date)
values(1,'Lisa','Simpson','03/01/2008','06/14/2008 19:36');
insert into report(user_id,first,last,report_date,actual_date)
values(1,'Bart','Simpson','03/01/2008','06/17/2008 19:37');
insert into report(user_id,first,last,report_date,actual_date)
values(1,'Bart','Simpson','05/01/2008','06/11/2008 15:37');
I would like to get a unique list of of all the users.
Thanks,
Tom
|
|
|
|
Re: how to write this sql query [message #324988 is a reply to message #324962] |
Wed, 04 June 2008 12:51 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
bztom33 wrote on Wed, 04 June 2008 12:36 | Hi,
How can I query a unique list of users?
create table report(
user_id number,
first varchar2(20),
last varchar2(20),
report_date date,
actual_date date,
constraint report_pk primary key (user_id,report_date,actual_date);
|
orcl10g SCOTT>l
1 create table report(
2 user_id number,
3 first varchar2(20),
4 last varchar2(20),
5 report_date date,
6 actual_date date,
7* constraint report_pk primary key (user_id,report_date,actual_date)
orcl10g SCOTT>/
constraint report_pk primary key (user_id,report_date,actual_date)
*
ERROR at line 7:
ORA-00907: missing right parenthesis
So, I took the effort to fix that problem, then
orcl10g SCOTT>l
1 insert into report(user_id,first,last,report_date,actual_date)
2* values(1,'Jane','Doe','01/01/2008','06/04/2008 09:36')
orcl10g SCOTT>/
values(1,'Jane','Doe','01/01/2008','06/04/2008 09:36')
*
ERROR at line 2:
ORA-01843: not a valid month
[Updated on: Wed, 04 June 2008 12:52] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: how to write this sql query [message #325088 is a reply to message #325076] |
Thu, 05 June 2008 00:11 |
|
mintomohan wrote on Thu, 05 June 2008 09:47 | bztom33 wrote on Wed, 04 June 2008 22:06 | Hi,
How can I query a unique list of users?
|
Please define user.
If user_id is same for all users, which all column should we select to identify a user ?
Regards
Minto
|
if we can concatinate the first and last name, then group by with the full name, then i think it will work.
|
|
|
Re: how to write this sql query [message #325110 is a reply to message #325088] |
Thu, 05 June 2008 01:03 |
mintomohan
Messages: 104 Registered: November 2006 Location: India
|
Senior Member |
|
|
itech wrote on Thu, 05 June 2008 10:41 |
if we can concatinate the first and last name, then group by with the full name, then i think it will work.
|
What if there are two users with the same first name and last name ?
Regards
Minto
|
|
|
Goto Forum:
Current Time: Thu Dec 12 23:48:00 CST 2024
|