473,387 Members | 3,684 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,387 software developers and data experts.

min function doesn't work

I have a query that gives me a desired result of 700 records. The query is being run on a table:

SELECT Min(my.number) AS numberOfMin, my.hello, my.boy, my.girl, my.truck, my.kid, my.mom, my.dad, my.man, my.woman, my.duck, my.goose, my.cat
FROM my
GROUP BY my.hello, my.boy, my.girl, my.truck, my.kid, my.mom, my.dad, my.man, my.woman, my.duck, my.goose, my.cat;


If, however, I add one more column (added at end of query - my.dog), I get one more record returned in my output than desired (a result of 701 records):

SELECT Min(my.number) AS numberOfMin, my.hello, my.boy, my.girl, my.truck, my.kid, my.mom, my.dad, my.man, my.woman, my.duck, my.goose, my.cat, my.dog
FROM my
GROUP BY my.hello, my.boy, my.girl, my.truck, my.kid, my.mom, my.dad, my.man, my.woman, my.duck, my.goose, my.cat, my.dog;

If I add the remaing columns in the table, I get even more results (records)
What is going on here? I am baffled. . . The results just go up as I add more columns
Sep 6 '07 #1
2 2596
barry07
47
The GROUP BY statement means that the query returns a value for every UNIQUE combination of the selected fields, so as you add more fields you create more combinations.

e.g if I have the following values in a table

Col1|Col2|Col3
A|B|C
A|C|B
A|B|D

Then if I select Col1 and group by Col1 I get only the value A
If I select Col1 and Col2 group by Col1, Col2 I get:

AB, and AC only.
(Since the combination AB is repeated it will only be selected once.)

Selecting all 3 and grouping on all 3 returns everything because all combinations are unique - i.e there are no repeated combinations over the 3 columns.

Hope this helps
Sep 6 '07 #2
Ok, thanks a lot. Still just getting started with access / DBs in general.

So I suppose the best way to select entire records from a table based on a min value is to run a query using 2 columns, the group by column that I want to group with and the min column. Then I can use the results from this query with a table to pull the records I am interested in with the additional columns.

Thanks for the help!
Sep 7 '07 #3

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

Similar topics

3
by: Mike | last post by:
Hi all, I've been trying to get imagerotate() working with PHP 4.4.3 and the latest version of GDlib. An error message is given saying the function is unrecognised. Can anyone advise which...
2
by: Ruslan V. Sulakov | last post by:
The situation: root@oasis2# cat test.php ; echo "---------"; php test.php <?php $string = 'April 15, 2003'; $pattern = '/(\w+) (\d+), (\d+)/i'; $replacement = '${1}1,$3'; echo...
7
by: Amir | last post by:
I have a common Jscript function in my "common.js" file It is: function submitForm(frm,action){ frm.action=action; frm.submit(); return(false) }
2
by: Amir | last post by:
I used FireFox Jscript debuging capabilities but it says: frm variable doesn't have the property Action function submitForm(frm,action){ frm.action=action; frm.submit(); return(false) }...
7
by: kdc | last post by:
Hello, I would appreciate any help I can get from anyone who has experience using javascript. I have an html form containing a number of functions controlling the submission of data to our...
2
by: Alan | last post by:
Hi all, I want to hilight some syntax keywords. While parsing text, I used these properties such as SelectionStart,SelectionLength and SelectionColor of RichTextBox. Although the syntaxhilghting...
5
by: enno | last post by:
Dear Community, We have a problem with null-Bytes in varchar-Columns, which are not handled correctly in our application. Therefor we try to filter them out using the Transact-SQL REPLACE...
3
by: Andrew | last post by:
I need to call a function inside another function, but I don't know the function name. I solved in this way: function x (newFunc) { eval(newFunc+ "()"); } Again this work for Firefox and...
4
by: shaiful | last post by:
Hi all, I used mail function to send a mail. the code: <?php $to = "shaiful@vvv.com"; $subject = "New Online Prayer Request"; $message ="kk"; $txtReply = "ll"; ...
2
by: Bouzy | last post by:
I am trying to go through words in a list of words and take out all the '.'s. I made the function ... def clearup(tor): tor = tor.replace('.', '') words = fcheck.read().split() for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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:
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
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...

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.