Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie to SQL

Status
Not open for further replies.

Dausa67

Technical User
Oct 1, 2008
96
US
So here is what I have so far. I did not create the table however, I did create the SQL statement.

Code:
 select a.created_on, a.itemid, a.quantity, a.workorder
from trakstar.workitem a
where rownum <=8

My end result is

Code:
[B]CREATED_ON      ITEMID        QUANTITY   WORKORDER[/B]
25-MAY-06	F7XC259001017|||	1	F00172848
25-MAY-06	ITEM32|||	        2	F00172848
25-MAY-06	NAS1149F0332P|||	11	F00172848
25-MAY-06	NAS1149FN632P|||	8	F00172848
25-MAY-06	NAS1834-3-375|||	14	F00172848
25-MAY-06	NAS1836-06-07|||	8	F00172848
25-MAY-06	NAS1836-06-7|||	        9	F00172848
11-MAY-06	F9DJ110007A0303|||	7	F00169372

I ran it so it would only pick up 8 rows. I actually want it to pull back all records that have a create date between 01/01/2008 and 12/31/2008. I also want to be sure that there are no duplicates.

The floor is open for correction..



Clay
 
Clay,

You can achieve the DATE specification you want by replacing your WHERE clause with:
Code:
...
WHERE a.created_on between to_date('01/01/2008','mm/dd/yyyy')
                       and to_date('12/31/2008 23:59:59','mm/dd/yyyy hh24:mi:ss')
...and alternate code that will not use indexes, but is simpler code is:
Code:
...
WHERE to_char(a.created_on,'yyyy') = '2008'
Now, insofar as your "no duplicates" specification is concerned...Do you want to ensure, now and forever, that no duplicates are in your data, or do you simply not want to see duplicates as part of your result set?

And furthermore, how many duplicated values (columns) on two rows constitute a duplicate? All columns? Less than all?

Let us know.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top