|
-
Select Distinct
I've noticed there's been a lot of questions on the select distinct statement,
and in many tries, I can't figure out how to use this correctly in my scenario.
I currently have 2 DBs - one that lists products and one that lists all items
that have been signed out (or in) at any time. This is for inventory purposes.
I am trying to create an HTML table that lists each of the items only once
with the last time they've been signed out/in or blank if they've never been.
My code currently is
SELECT DISTINCT EQUIPMNT.SERIALNUM, EQUIPMNT.NAME SIGNOUT.STATUS, SIGNOUT.RACFID,
SIGNOUT.DATEOUT, SIGNOUT.DATEIN, FROM WEBSRV.SIGNOUT RIGHT JOIN WEBSRV.EQUIPMNT
ON SIGNOUT.SERIALNUM=EQUIPMNT.SERIALNUM
ORDER BY SIGNOUT.DATEOUT DESC
This code still lists items that have been signed out/in more than once,
multiple times. I've tried using sub-queries, but I'm not quite sure of
the exact syntax to make this work correctly.
Hopefully this is enough information. Thanks to anyone who can help!
Cary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks