473,411 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

getting top count across multiple fields

although i don't think this is do-able using SQL, i would ask and maybe
an expert can help me out. assum i have the following table:

Date Code Count
2006-06-06 abc 1234
2006-06-06 abc 14
2006-06-06 abc 87
2006-06-06 xyz 1353
2006-06-06 xyz 19
2006-06-06 xyz 86
2006-06-06 xyz 176
2006-06-06 xyz 43
2006-06-06 ppp 67
2006-06-06 ppp 45
2006-06-06 ppp 200

what i want is the top 2 Count from each Code for Date like this:

Date Code Count
2006-06-06 abc 1234
2006-06-06 abc 87
2006-06-06 xyz 1353
2006-06-06 xyz 176
2006-06-06 ppp 200
2006-06-06 ppp 67

obviously the following doesn't work:

select Date,Code,Count from myTable group by Date,Code,Count order by
Count desc limit 2

because the order and the limit will be across the whole table not code
by code so you end up with only 2 rows with count 1353 and 1234.

any idea if this is do-able using SQL only?

Jun 11 '06 #1
0 1650

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

Similar topics

1
by: Bill | last post by:
I'm submitting data through a form with multiple rows on it, that goes out to a processing page, which then scrolls through the data row by row and sends it into a database table. It is...
2
by: Alex | last post by:
Hi all, I'm running into a road block, and I know I've done this before. I'm getting fields from two tables, and I need to do a count of similar items with it showing some extra info. Here's...
2
by: JimJim | last post by:
Wondering if someone here could help me out, I've tried a number of ways to do this, and while I have managed to get it to work, Im SURE im not doing the optimal way, and it seems to be causing...
1
by: Chris Wolfe | last post by:
I have two fields that draw their combobox values from the same table. LogBook04.Insurance is the Primary Insurance and LogBook04.SecIns is the Secondary Insurance. Both draw their values from...
3
by: Zb Bornemann | last post by:
Hi All, Ok. Here's what my table looks like: Field1 Field2 Field3 Field4... Record1 1 3 2 9 Record2 9 1 9 ...
2
by: cefrancke | last post by:
I can't seem to find a straight answer for my specific issue. Any help would be appreciated. I would like to count the various items in a table where the fields have a 'group' relationship. I...
1
by: griemer | last post by:
I have a database like this id, field1,field2,field3,field4,field5 Database contains 100 rows, some rows have no fields filled, some 1field , some 2 fields etc. How would i count the...
1
by: sunilkeswani | last post by:
Hi I am still new to access. I want to know how i can build a query which can display results from 4 different columns/fields Like. Field1 Field2 Field3 Field4 1 2 1 ...
22
by: Sri | last post by:
All Recenetly our shop migrated to DB2 V8 from V7. We are in IBM System Level: z/OS 1.6.1 @ RSU 0702. Processor : IBM 2064-1C7 (z/900) # 1B89 Mode: 64-bit One of my application is facing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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
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,...
0
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
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...

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.