473,508 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need an sql query for the following situation

58 New Member
i need a query to get a collection ...
Following is the situation.
ive got a collection in which item of each element is different.
but each element has an item_id tat can be same.all these elements have weightage... i need to get elements with unique item_id and max weightage.
ie;
i got a collection of elements such as

e1 with item_id as 1 and weightage 7
e2 with item_id as 2 and weightage 10
e3 with item_id as 1 and weightage 8
e4 with item_id as 5 and weightage 10
e5 with item_id as 6 and weightage 10
e6 with item_id as 1 and weightage 6
so my result collection should contain the elements
e3 with item_id as 1 and weightage 8
e2 with item_id as 2 and weightage 10
e4 with item_id as 5 and weightage 10
e5 with item_id as 6 and weightage 10


can i get this in a single sql query? please help
Jun 15 '07 #1
4 1127
Purple
404 Recognized Expert Contributor
Hi,

are you asking for the item with the highest weightage in each item id ?

Purple
Jun 15 '07 #2
shiniskumar
58 New Member
Hi,

are you asking for the item with the highest weightage in each item id ?

Purple
i need toi get chck the maximum weightage only for those elements whose item_id are the same
Jun 15 '07 #3
Purple
404 Recognized Expert Contributor
Hi,

I am sorry, I don't understand - are you asking for the maximum / hightest weightage in each group of item_ids ?

Purple
Jun 15 '07 #4
Purple
404 Recognized Expert Contributor
Hi,

try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT     item, item_id, MAX(weightage) AS max_weightage
  2. FROM         YOUR_TABLE
  3. GROUP BY item_id
Regards Purple
Jun 15 '07 #5

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

Similar topics

3
2241
by: Paul Janssen | last post by:
Hello! Can anyone help me out with the following situation: (a) a single query with 550 id's in the IN-clause resulting into 800+ seconds; (b) 550 queries with a single id in the IN-clause...
1
3313
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently...
3
10606
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
9
23689
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the...
6
4815
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
20
4077
by: Tony | last post by:
I have a situation where I want to send data, but I have no need for a response. It seems to me that XMLHTTPRequest is the best way to send the data, but I don't need any response back from the...
2
2344
by: Venk | last post by:
hi all, I saw one reply to arun on the subject "Dynamic Query in Ms-Access" by one Mr Rick I found it very useful. Now to extend this solution forward I have the following situation. I...
3
4131
by: Martini | last post by:
Hello all. I have quite disturbing situation where I am not happy about the way how SQL handles the query. Situation is related to using user function in INNER JOIN select. Although the problem...
5
1525
by: Karthik D V | last post by:
Hello All, I have a table like this ID CHARACTER ----------- --------- 1 A 2 A 3 B 4 B
1
1976
by: shiniskumar | last post by:
i need a query to get a collection ... Following is the situation. ive got a collection in which item of each element is different. but each element has an item_id tat can be same.all these...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
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...
0
7489
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...
0
5624
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,...
1
5047
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...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.