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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a max query

Status
Not open for further replies.

inarobis

IS-IT--Management
Joined
Apr 3, 2006
Messages
71
Location
CH
I have this view:

SELECT MAX(DERIVEDTBL.[Time]) AS Time, DERIVEDTBL.[Value], DERIVEDTBL.Date, MIN(DISTINCT DERIVEDTBL.Name) AS name
FROM (SELECT *
FROM f_view -- another view
WHERE (Date =
(SELECT MAX(date) AS maxdate
FROM f_view v
WHERE v.name = f_view.name))) DERIVEDTBL

GROUP BY Date, Type, Status, [Value]
HAVING (Status = 0) AND (Type = 0)


My query:
Select value, time from sample_view where name = Marianne' AND date BETWEEN '2006-02-01' AND '2006-02-28' group by name, value

I would like to have this value:
time |value |date |name
---------------------------------------------------
2006-03-28 14:01:28.123 109.81 2006-02-28 Marianne


And I have this two value if even I did the max of time.
time |value |date |name
----------------------------------------------------
2006-03-28 14:01:28.123 109.81 2006-02-28 Marianne
2006-03-27 14:41:07.167 261.6 2006-02-28 Marianne

When I insert in my query the column value I have this two record displayed.

I tried to do the max of time but I have all the time the same result.



Thank you in advance

Inarobis



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top