Re: SQL MIN() et VFP MIN()

2014-10-30 Thread Bill Anderson
Jean, Ok, let's try it this way...if you take out the ta. references in the CAST field does the SQL run or fail? Bill Anderson On Wed, Oct 29, 2014 at 7:14 AM, Jean MAURICE jsm.maur...@wanadoo.fr wrote: Hi Bill, this is not an error ! cantine_services and cantine_salles are linked together

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Jean MAURICE
Hi Bill : unknown alias ta ! The Foxil Le 28/10/2014 22:08, Bill Anderson a écrit : Jean, That should fail. The column names would not be available to be used in the SELECT portion of the clause. If you use the HAVING clause as part of the join, the column names are available to be used.

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Laurie Alvey
The only way I've found to do this is to use an external function, like this: CLOSE DATABASES ALL *!* Source tables have 100 rows of random integers USE colmin1.dbf USE colmin2.dbf IN 0 USE colmin3.dbf IN 0 USE colmin4.dbf IN 0 CREATE CURSOR cout (f1 I, f2 I, f3 I, f4 I, minv I) INSERT INTO

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Stephen Russell
On Wed, Oct 29, 2014 at 7:25 AM, Laurie Alvey trukke...@gmail.com wrote: The only way I've found to do this is to use an external function, like this: CLOSE DATABASES ALL *!* Source tables have 100 rows of random integers USE colmin1.dbf USE colmin2.dbf IN 0 USE colmin3.dbf IN 0 USE

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Bill Anderson
Jean, I think issue is a flaw in the JOIN. I don't see how ta ties to the rest of the join. FROM cantine_services sv ; INNER JOIN cantine_salles sal ON sv.salle = sal.clef, ; tarifs_cantine ta ; WHERE ta.anscol = lcannee INTO CURSOR I don't see how tarif_cantine (ta)

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Virgil Bierschwale
I did something similar to what steve said, and I basically put all the data in one merged table and did the following mysql query on it SELECT V, U, H, MIN(cast(P as decimal)) AS L_SALARY, MAX(cast(P as decimal)) AS U_SALARY, SUM(T) AS W_COUNT, COUNT(U) AS H_COUNT FROM `wp_lca_2013` where

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Jean MAURICE
Hi Bill, this is not an error ! cantine_services and cantine_salles are linked together (it's a school restaurant, pupils are dispached in 4 groups that eat in 2 rooms) but tarifs_cantine is independant (it's the cost of different menus) and I want a 'cartesian product' (?) : on line per

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Jean MAURICE
today, the simplest way to solve the issueis the ICASEgiven by Paul Hill. The Foxil ___ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list:

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Ricardo Molina
You don't have to make as many comparisons as Paul suggested, make 3 comparisons, then 2 then 1: SELECT DISTINCT ta.codtarif AS tarif, ; sv.clef AS clefserv, sv.salle, sv.capacite AS servdispo, sv.libelle AS service, ; sal.capacite AS salledispo, sal.libelle AS nomsalle, ; ta.capacite AS

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Bill Anderson
Jean If you take out the Disponible field does the query work and produce accurate results? Bill Anderson On Wed, Oct 29, 2014 at 3:39 AM, Jean MAURICE jsm.maur...@wanadoo.fr wrote: Hi Bill : unknown alias ta ! The Foxil Le 28/10/2014 22:08, Bill Anderson a écrit : Jean, That should

Re: SQL MIN() et VFP MIN()

2014-10-29 Thread Jean MAURICE
Yes. For years I have written CAST(O AS Integer) AS disponible in the SQL query followed by a REPLACE ALL after the query. The Foxil Le 29/10/2014 16:21, Bill Anderson a écrit : Jean If you take out the Disponible field does the query work and produce accurate results? Bill Anderson

SQL MIN() et VFP MIN()

2014-10-28 Thread Jean MAURICE
I have a curious issue ! In a SQL query, I get 4 numeric fields from 4 tables (with subqueries). I want a fifth field containing the minimum value of the 4 fields (of the current line). But when I write MIN(), even in an EVALUATE command, SQL thinks it is a SQL MIN(). Is there a way to

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Bill Anderson
Jean, I remember submitting a tip to the Foxpro Advisor for this very issue. But offhand I don't remember what the answer was. I wrote the tip using MAX() but it applied to MIN() as well. If someone doesn't come up with the answer in a few hours I'll look into it further. But there *is* an

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Stephen Russell
On Tue, Oct 28, 2014 at 12:17 PM, Jean MAURICE jsm.maur...@wanadoo.fr wrote: I have a curious issue ! In a SQL query, I get 4 numeric fields from 4 tables (with subqueries). I want a fifth field containing the minimum value of the 4 fields (of the current line). But when I write MIN(), even

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Jean MAURICE
Hi Stephen, I am getting a single cursor with a lot of columns; 4 of them are numeric and one more is '000.00 AS minimum' The Foxil ___ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Stephen Russell
On Tue, Oct 28, 2014 at 2:14 PM, Jean MAURICE jsm.maur...@wanadoo.fr wrote: Hi Stephen, I am getting a single cursor with a lot of columns; 4 of them are numeric and one more is '000.00 AS minimum' Guessing that you are joining tables to pull the 4 columns. If instead

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Paul Hill
On 28 October 2014 17:17, Jean MAURICE jsm.maur...@wanadoo.fr wrote: I have a curious issue ! In a SQL query, I get 4 numeric fields from 4 tables (with subqueries). I want a fifth field containing the minimum value of the 4 fields (of the current line). But when I write MIN(), even in an

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Bill Anderson
Jean, First, this... (VFP 9 specific) USE ADDBS(HOME(1)) + [Browser.DBF] SHARED NOUPDATE SELECT CAST(EVALUATE([MIN(1, 2, 3, 4)]) AS N(7, 2)) AS MinimumTest FROM Browser INTO CURSOR Test That shows how to use the VFP MIN() function in a SQL Select while formatting the MinimumTest field. So in

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Jean MAURICE
I try it at once(I already tried with EVALUATE alone but it failed) The Foxil Le 28/10/2014 21:12, Bill Anderson a écrit : Jean, First, this... (VFP 9 specific) USE ADDBS(HOME(1)) + [Browser.DBF] SHARED NOUPDATE SELECT CAST(EVALUATE([MIN(1, 2, 3, 4)]) AS N(7, 2)) AS MinimumTest FROM Browser

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Jean MAURICE
Hi Bill, it failed ! here is a small SQL query : SELECT DISTINCT ta.codtarif AS tarif, ; sv.clef AS clefserv, sv.salle, sv.capacite AS servdispo, sv.libelle AS service, ; sal.capacite AS salledispo, sal.libelle AS nomsalle, ; ta.capacite AS maxtarif, ta.maxjour AS maxjour, ta.libelle

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Jean MAURICE
a little more : writing the table name instead of local alias avoid the syntax error but the result is wrong. SELECT DISTINCT ta.codtarif AS tarif, ; sv.clef AS clefserv, sv.salle, sv.capacite AS servdispo, sv.libelle AS service, ; sal.capacite AS salledispo, sal.libelle AS

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Bill Anderson
Jean, That should fail. The column names would not be available to be used in the SELECT portion of the clause. If you use the HAVING clause as part of the join, the column names are available to be used. Replace the Disponible field with this and see if it works:

Re: SQL MIN() et VFP MIN()

2014-10-28 Thread Gianni Turri
Hi Maurice, I suspect that using EVALUATE you cannot refererence fields and values from inside the query, you can only reference fields and values from the VFP environment before running the query. Gianni On Tue, 28 Oct 2014 21:36:36 +0100, Jean MAURICE jsm.maur...@wanadoo.fr wrote: a little