473,624 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I would like to simplify my query

15 New Member
What I'm trying to do is get the last entry (by date) for a given entity (which should be a single row). The following returned more than one row:

select termId, entityId, max(enddate)
from Terms
where entityId = 1234
group by termId, entityId

This does return me one row:

select *
from Terms
where enddate in (select max(enddate)
from Terms
where entityId = 1234)

What I would like to do this in one select statement. Does anyone have any suggestions?
Jul 13 '07 #1
1 988
hariharanmca
1,977 Top Contributor
What I'm trying to do is get the last entry (by date) for a given entity (which should be a single row). The following returned more than one row:

select termId, entityId, max(enddate)
from Terms
where entityId = 1234
group by termId, entityId

This does return me one row:

select *
from Terms
where enddate in (select max(enddate)
from Terms
where entityId = 1234)

What I would like to do this in one select statement. Does anyone have any suggestions?

I think your query is correct. I can’t get what you mean for simplify my query?

If you want you have to explain your requirement
Jul 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

303
17572
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
22
1737
by: Alan | last post by:
I have many OR in the if statement, any method to simplify? if (val == 5 | val == 9 | val == 34 | val == 111 | val == 131 | .......) // .... thank you
6
13131
by: pragile | last post by:
I have a stored procedure that has some problems with slow performance. The procedure has 2 parameters @firstname varchar(100) @lastname varchar(100) These parameters can have values like a%, that is wildcard searches. The strange thing is that if one of the parameters has the value %, and the other one a%, the performance is very bad. If i subsistute the variables with exactly the same values hardcoded in
0
2298
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies (http://www.datadirect.com), the software industry leader in standards-based components for connecting applications to data and an operating unit of Progress Software Corporation, today announced the release of DataDirect XQuery(TM), the first embeddable...
3
2844
by: Bob Bedford | last post by:
hello I'm looking for some functions or objects allowing to select-insert-update-delete from any table in a mysql database without the need to create a new query every time. Example: selectdatas(array('field1','field2','fieldn'),array('table1','tablen'),array('left join,idy','inner join, idx')) then the function build the query, execute it and then return an object with
6
1888
by: Patrick | last post by:
Hi All, Kind of new to this. What I have below works, but I am wondering if there is a way to make it more efficient/simpler instead of having to write an if, tr, td, blah for each datatype. How would I simplify this? Any thoughts are appreciated. Thanks, Patrick
1
6073
AmLegacy
by: AmLegacy | last post by:
I'm having a hard time figuring out how to simplify the fractions. Can anyone look at this code and see if you can see something I don't. //This is the fraction adding function void add_fractions (int a, int b, int c, int d, int *ansn, int *ansd) { //int e, x, y, rem, gcd; a = a*d; //numerator 1 * denominator 2 c = c*b; //numerator 2 * denominator 1 b = b*d; // denominator 1 * denominator 2 d = b; //denominator 2 = denominator 1
3
1380
by: Hvid Hat | last post by:
Hi I've got the following XSLT that works but I'm trying to figure out how to simplify it. There is only one Image, so I don't need the for-each-loop. Anyone? <xsl:for-each select="Data/img"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="class">right</xsl:attribute>
5
3656
by: Jon Skeet [C# MVP] | last post by:
On Sep 9, 9:41 am, raylopez99 <raylope...@yahoo.comwrote: It's tricky in .NET for two reasons: 1) LINQ doesn't have any concept of "remove" 2) List<T>.RemoveAll doesn't pass in the index (which makes sense as it would then need to If List<Tsupported some sort of "view" which also exposed RemoveAll, it would be easy:
0
8240
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.