Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with HAVING clause
Message
De
15/02/2007 15:08:51
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01196229
Message ID:
01196234
Vues:
11
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Gang!
>
>I am throwing together some SQL, and ran into a snag
>
>I have a table pse_trans with the follwing fields
>
>
>quan_pur  N 8-3
>prod_upc  C-12
>trans_dt  DateTime
>
>
>and a table pse_drug with the following field
>
>
>upc       C-12
>
>
>When I run the following code to extract all the records from pse_trans table
>that have a certain UPC and within the past 24 hours (86400 seconds)
>
>
>SELECT SUM(quan_pur) AS Sum24TransUPC, prod_upc FROM pse_trans ;
>	GROUP BY prod_upc ;
>	HAVING prod_upc = pse_drug.upc ;
>		AND trans_dt >= (DATETIME() - 86400) INTO CURSOR TwentyFourHoursQuantUPC
>
>
>I get an error - 'SQL: Having Clause is Invalid'
>
>When I take the AND trans_dt >= (DATETIME()-86400) out of it, it works without an error.
>
>What is obviously wrong???
>
Why do you need to use pse_drug table here? It could be:
SELECT SUM(quan_pur) AS Sum24TransUPC, prod_upc FROM pse_trans ;
  INTO CURSOR TwentyFourHoursQuantUPC
  Where trans_dt >= (DATETIME() - 86400) ;
  Group by 2
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform