fsttik has dashes in it and your having does not.
Either add dashes to your having or change the alias to min(datein+0) as fsttik.



Patrick Shoaf wrote:


I am trying to get a SELECT working and not having any luck, can someone please help?

SELECT strref,acc.acctno,acc.namelast,acc.namefirst,phone1,adddate,min(datein) as fsttik, sum(amt) as sales,store FROM acc,sdtik WHERE acc.acctno=sdtik.acctno and voidreason=0 and store>=40 and store<=59 GROUP by acc.acctno ORDER BY fsttik DESC LIMIT 20;

results in the following data:

strref acctno namelast namefirst phone1 adddate fsttik sales store
1 52 9266 BROUNCE GALE 7242586226 2002-01-26 2003-07-08 15.50 52
2 52 2194 HOPKINS PATTY 7244838865 2001-09-14 2003-07-08 0.00 52
3 52 15622 CLARK MARGARET/DAN 7248340156 2002-07-09 2003-07-08 85.92 52
4 51 27211 SEDNEY ED 7244899547 2003-07-08 2003-07-08 62.50 51
5 51 8854221 KASZAK KIRK 4122764951 1996-11-18 2003-07-07 26.02 51
6 51 27093 GLAZER BONNIE 4122761287 2003-07-02 2003-07-02 3.50 51
7 52 26842 HARBAUGH FRAN,DAN 7245377227 2003-06-22 2003-07-01 38.22 52
8 51 26726 KING RICHARD 4124003773 2003-06-18 2003-07-01 18.72 51
9 51 622 MILLER ROBERT/DENISE 4122578375 2001-08-21 2003-06-30 17.82 51
10 7 8336322 HORNBAKE JOAN 4128336322 2001-03-23 2003-06-27 26.78 51
11 51 26219 BERKO MIKE 4126750648 2003-05-30 2003-06-26 7.60 51
12 51 26736 SCHMULEVICH RAFAEL 4122720518 2003-06-18 2003-06-19 6.73 51
13 52 26642 FAWCETT CHUCK/SUSAN 7249423761 2003-06-16 2003-06-19 94.62 52
14 51 26401 ZYWAN JOHN 7248734686 2003-06-05 2003-06-19 35.02 51
15 51 26738 SCOTT BETH 4122573588 2003-06-18 2003-06-19 29.77 51
16 51 26729 KURLANDER CARL 4126820382 2003-06-18 2003-06-18 45.27 51
17 51 26734 MEEKS JULIE 4124295354 2003-06-18 2003-06-18 0.00 51
18 52 8721884 GAUDINO LARRY 7248721884 2001-06-09 2003-06-18 133.90 52
19 51 26730 PRAKASH PREM 4126875411 2003-06-18 2003-06-18 4.95 51
20 51 26732 SOUTHORN LAURIE/ROBERT 4122570383 2003-06-18 2003-06-18 29.23 51


When I change the SQL SELECT to read:

SELECT strref,acc.acctno,acc.namelast,acc.namefirst,phone1,adddate,min(datein) as fsttik, sum(amt) as sales FROM acc,sdtik WHERE acc.acctno=sdtik.acctno and voidreason=0 and store>=40 and store<=59 GROUP by acc.acctno HAVING fsttik>=20030701 ORDER BY fsttik DESC LIMIT 20;

I do not receive any records back. What is the proper method to retrieve based on MIN(datein)?

Any/All help greatly appreciated...



Patrick J. Shoaf, Systems Engineer
<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]

Midmon Internet Services, LLC
100 Third Street
Charleroi, PA 15022
http://www.midmon.com
Phone: 724-483-2400 ext. 105
 or    888-638-6963
Fax:   724-489-4386






-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to