473,461 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL for frequency-related results

PI
Hi guys,
I need some assistance please: Since PHP guys usually have SQL skills,
I decided to post this question here. How do I structure a SQL command
to return frequency-related results from a database. For example, if I
wanted the query to return the top 5 entries in a table within
specified dates. By top 5 (N), I mean the records (values) in a given
table that have occurred the most within that table. Perhaps, to help
you help me, if user requests for a product were entered into a table,
and I wanted to find out the most requested product in the month of
May or within the last 6 months, how will the SQL query be please?
Thanks.
Nov 17 '08 #1
5 2312
PI
Hi Guys,
The following information is added to make my question clearer

The table schema is:
+---------------+--------------+------+-----+---------+----------------
+
| Field | Type | Null | Key | Default | Extra
|
+---------------+--------------+------+-----+---------+----------------
+
| requestID | int(15) | NO | PRI | NULL | auto_increment
|
| requestNum | varchar(255) | YES | | NULL |
|
| itemRequested | varchar(255) | YES | | NULL |
|
| quantity | int(15) | YES | | NULL |
|
| userEmail | varchar(255) | YES | | NULL |
|
| date | datetime | YES | | NULL |
|
| location | varchar(255) | YES | | NULL |
|
+---------------+--------------+------+-----+---------+----------------
+

And the table viewed may look like this:

+-----------+-------------+---------------+----------
+----------------------------+---------------------+--------------+
| requestID | requestNum | itemRequested | quantity |
userEmail | date | location |
+-----------+-------------+---------------+----------
+----------------------------+---------------------+--------------+
| 1 | 47569BZ | 03LH260 | 1 |
jo*@bloggs.co.uk | 0000-00-00 00:00:00 | Unknown |
| 2 | 47569BZ | 03LH459 | 1 |
jo*@bloggs.co.uk | 0000-00-00 00:00:00 | Unknown |
| 3 | 83284AD | 03LH260 | 1 |
jo*@bloggs.co.uk | 0000-00-00 00:00:00 | Unknown |
| 4 | 83284AD | 03LH459 | 1 |
jo*@bloggs.co.uk | 0000-00-00 00:00:00 | Unknown |
| 5 | 85669FJ | 03LH260 | 3 |
jo*@bloggs.co.uk | 2008-11-14 09:54:08 | Unknown |
| 6 | 85669FJ | 03LH459 | 7 |
jo*@bloggs.co.uk | 2008-11-14 09:54:08 | Unknown |
| 7 | 02429ZH | 03LH260 | 3 |
jo*@bloggs.co.uk | 2008-11-14 10:28:55 | Unknown |
| 8 | 02429ZH | 03LH459 | 7 |
jo*@bloggs.co.uk | 2008-11-14 10:28:55 | Unknown |
+-----------+-------------+---------------+----------
+----------------------------+---------------------+--------------+
Thanks

Nov 17 '08 #2
PI
problem solved - solution available at
http://groups.google.co.uk/group/com...e143e44?hl=en#
Nov 17 '08 #3
PI wrote:
problem solved - solution available at
http://groups.google.co.uk/group/com...e143e44?hl=en#
Which was the correct place to post this in the first place - this was
NOT a PHP question and should not have been posted in this newsgroup.

Additionally, when you do post in multiple newsgroups, please crosspost
- not multipost.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 17 '08 #4
PI
Thanks Jerry,
apologies for multiposting - but how do I crosspost instead?
Nov 17 '08 #5
PI wrote:
Thanks Jerry,
apologies for multiposting - but how do I crosspost instead?
If you look at the form when you post your message, one of the things it
says, right under the "To Newsgroups:" is:

(Separate multiple groups with commas)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 17 '08 #6

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

Similar topics

9
by: christopher diggins | last post by:
I would like to survey how widespread the usage of smart pointers in C++ code is today. Any anecdotal experience about the frequency of usage of smart pointer for dynamic allocation in your own...
11
by: NC Tim | last post by:
Hello, I think the question i have is fairly straightforward, but I can't seem to replicate the old SAS frequency procedure when I try to accomplish this in MS Access. anyway, i have about 10...
8
by: Pete | last post by:
I need to write a program to do a frequency analysis on a string of text. Firstly I need to get the alphabet A to Z for comparison but I'm not sure how to go about this. Is the following the...
19
by: jason_box | last post by:
I'm alittle new at C and I'm trying to write a simple program that will record the frequency of words and just print it out. It is suppose to take stdin and I heard it's only a few lines but I'm...
0
by: COBRA | last post by:
HI..could anyone help me out on this question? Consider the marks scored by students of a programming module. Allow the user to enter the number of students. The user shall then enter the marks...
6
by: Harryrun | last post by:
Hello am a beginner in programming and I came to a problem with a question in which I need to calculate the frequency of appearance of marks. I have used an array to store the marks but can only...
2
by: Krish06 | last post by:
Hi Friends, i just need to measure the frequency and ampitude from sound.. in my pro i create a sine wave(i set freq 1000hz,amptitude200) and i passed that wave sound to my pc thru...
7
by: Udhay | last post by:
How to get the frequency of an audio file and how to separate the low and high frequency of an audio file
8
by: Andrew Savige | last post by:
I'm learning Python by reading David Beazley's "Python Essential Reference" book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not...
13
by: umpsumps | last post by:
Hello, Here is my code for a letter frequency counter. It seems bloated to me and any suggestions of what would be a better way (keep in my mind I'm a beginner) would be greatly appreciated.. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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
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
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
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...
0
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.