Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query Latest Record Help

Author  Topic 

mikezdman
Starting Member

4 Posts

Posted - 2009-07-31 : 15:32:32
I have a view set up that includes a test year field. I am trying to set up the query to only return the records associeted with the newest test year. Here is the code I am using:

SELECT sdeuser.WATER_HYDRANT.SHAPE, sdeuser.WATER_HYDRANT.OBJECTID, sdeuser.WATER_HYDRANT.TAG, sdeuser.WATER_HYDRANT.SIZE_,
sdeuser.WATER_HYDRANT.MANUFACTURER, sdeuser.WATER_HYDRANT.CONNECTION_, sdeuser.WATER_HYDRANT.GND_ELEV,
sdeuser.WATER_HYDRANT.ELEVATION, sdeuser.WATER_HYDRANT.OWNER, sdeuser.WATER_HYDRANT.YEAR_INSTALLED,
sdeuser.WATER_HYDRANT.COMMENTS, sdeuser.WATER_HYDRANT.H20_NET, RMS.Test_Year, RMS.Years_Elasped, RMS.gpm_20psi, RMS.static,
RMS.residual, RMS.total_flow, RMS.press_drop, RMS.test_method, RMS.pitot_hydrant1, RMS.pitot_pitot1, RMS.pitot_opening1, RMS.pitot_discharge1,
RMS.pitot_hydrant2, RMS.pitot_pitot2, RMS.pitot_opening2, RMS.pitot_discharge2, RMS.pitot_hydrant3, RMS.pitot_pitot3, RMS.pitot_opening3,
RMS.pitot_discharge3, RMS.pitot_hydrant4, RMS.pitot_pitot4, RMS.pitot_opening4, RMS.pitot_discharge4, RMS.Completed_by, RMS.Test_Date
FROM sdeuser.WATER_HYDRANT INNER JOIN
RMS5SQL.dbo.hydrant_test_VIEW AS RMS ON sdeuser.WATER_HYDRANT.TAG = RMS.TAG

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-31 : 23:15:04
Duplicate Post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=130446
Go to Top of Page
   

- Advertisement -