473,785 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

first value of each itemid how ?

hi,
From below table want only the first value of each item id.

and how to get it, tried to use top n function in select statement
it takes only the first record.

itemid qty
1 10
1 5
1 15
2 20
2 15
4 10
4 5
4 2

How to get first record of each item only.

captain

Nov 13 '05 #1
2 1764
ca**********@ya hoo.com wrote:
hi,
From below table want only the first value of each item id.

and how to get it, tried to use top n function in select statement
it takes only the first record.

itemid qty
1 10
1 5
1 15
2 20
2 15
4 10
4 5
4 2

How to get first record of each item only.

captain


If your ItemID records have an autonumber, I would create a query
(Query1) that selects the ItemID and Qty and sort on ItemID,
ItemIDAutoNumbe r. That way the query will sort the records in the order
they were entered. Then create a Totals query using Query1, group on
the ItemID and select First for qty.

Access does not necessarily open up a table in sequential mode. So you
may end up with a First that may not be the first. Hopefully by
ordering it first by the authonumber you would get the true First entry.
Nov 13 '05 #2
Might try using the Max(qty).
Turn the Aggregation tool on. By default all fields selected will have
"Group By" on, change this to Max for the qty field.
SQL would look like
SELECT itemid, MAX(qty) as MaxOfqty
FROM tablename
GROUP BY itemid

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
953
by: Sparky Arbuckle | last post by:
Dim MyCookie as new httpCookie(myCookieName) FOR EACH myItem as DictionaryEntry in htCart myCookie.Values(myItem.Key) = myItem.Value Dim objConn as new OLEDBConnection(ConfigurationSettings.AppSettings("NEWConnection")) Dim strSQL as string = "SELECT ITEMID, itNAME, itPRICE, itIMAGE " & _ "FROM tblITEMS WHERE ITEMID = '" & myItem.Key &
3
3126
by: webserverpete | last post by:
I am new to ASP.NET in general, but I do have experience with classic ASP. I am using a DataList control with a hidden value to submit to a different page, however I do not know how to get to that hidden value. Here is my DataList control code: <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4"> <ItemTemplate> <%#DataBinder.Eval(Container.DataItem, "itemname")%> <br>...
1
3025
by: Slonocode | last post by:
I have a collection of objects in a hashtable. The objects have a datamember that is empty. I need to loop through the items in the hashtable and add data to the datamember that is empty. htShippingItems is the hashtable which contains a collection of ShippingItems. Each shipping item has a datamember called Itemized that I need to populate with a string.
1
1764
by: kb222 | last post by:
This is probabally more simpler than I am making it but all I am trying to do is count the number of recrods in a child table where my IteimID number matches. I have the following code: nAdd = DCount("*", "AddComment", "='" & Me.ItemID.Value & "'") this works fine until I try and do the where clause. Access keeps telling me there is a data type mismatch. The me.itemid.value is an auto number and the ItemID is the child id which matches the...
2
1517
by: zb | last post by:
Scenario: I have a datalist control bound to a datasource. By itself, this works just fine. Now, inside the ItemTemplate I have a custom user control (I wrote this user control) and it has an itemId property exposed so I can assign this Id based on which it process other info. How implemented: <uc:processItem id="ucProcess" itemId="32e43432" runat=server /> Inside the parent repeater control this is what I am doing:
0
1323
by: Richard | last post by:
A container holds items that can be arranged by a person. A container may contain only one of a given item. Containers ----- ContainerId (unique) ContainerName (unique) other columns Items
0
2012
by: =?ISO-8859-2?B?UmFmYbMgR2llemdhs2E=?= | last post by:
I have: protected void InitControls() { gvProfile.AutoGenerateColumns = false; DataTable dtProfile = new DataTable("KFS"); // dodajemy kolumny foreach(DataGridViewColumn dc in gvProfile.Columns) { DataColumn ndc = new DataColumn();
2
2450
by: sunilkes | last post by:
Hello, I have a table ItemID Version 12 1.0 12 1.1 12 2.0 13 2.0
0
1071
by: rajesh0303 | last post by:
Iam get null values in the datakeynames AlertID,ItemID while executing the Insert Command....I am Inserting using Externel button Event.Here is the code of Gridiew ,Its datasource and the button event......Need help.... <asp:GridView ID="GridView2" DataSourceID="SqlDataSource2" DataKeyNames="AlertID,ItemID" AutoGenerateColumns="False" runat="server" Width="839px" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True"> ...
0
9647
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
10161
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
10098
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,...
1
7506
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
5390
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
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.