Re: SQL Help

2018-06-04 Thread Bob Sneidar via use-livecode
By the way, you can always get all matching records, convert to text, then sort the lines and get the first line. Bob S > That will only return the maximum value, not the record itself. > > Bob S > > >> On Jun 1, 2018, at 20:01 , prothero--- via use-livecode wrote: >> >> I’m thinking some

Re: SQL Help

2018-06-03 Thread Erik Beugelaar via use-livecode
Group by Get Outlook for Android On Sun, Jun 3, 2018 at 7:45 PM +0200, "Bob Sneidar via use-livecode" wrote: That will only return the maximum value, not the record itself. Bob S > On Jun 1, 2018, at 20:01 , prothero--- via use-livecode wrote: > > I’m thinking something

Re: SQL Help

2018-06-03 Thread Bob Sneidar via use-livecode
That will only return the maximum value, not the record itself. Bob S > On Jun 1, 2018, at 20:01 , prothero--- via use-livecode > wrote: > > I’m thinking something like: > > Select max(“iStoreGrp”) from “valveFlowsA” where (“valveNum”=n1 AND > “meterNum”=n2) > > Then I have to sort out ho

Re: SQL Help

2018-06-02 Thread William Prothero via use-livecode
Paul: Thanks, the suggestion you made worked. I used: put "SELECT * FROM "&theTable&" WHERE "&col1Name&" = "&col1Value&" AND "&col2Name&" = "&" order by iStoreGrp desc limit 1" into theQuery This returns the row with the specified meterNum and valveNum and the maximum value of iStoreGrp. Thanks

Re: SQL Help

2018-06-02 Thread Paul Dupuis via use-livecode
Sorry, I missed the all columns bit. Yes, LIMIT is the way to do this SELECT * FROM valveFlowsA WHERE meterNum =1 AND valveNum =3 ORDER BY iStoreGrp DESC LIMIT 1 If you still need it. The DESC insure the record with the highest (max) iStoreGrp value is returned first. CAUTION: If the data contain

Re: SQL Help

2018-06-01 Thread prothero--- via use-livecode
I’m thinking something like: Select max(“iStoreGrp”) from “valveFlowsA” where (“valveNum”=n1 AND “meterNum”=n2) Then I have to sort out how to put the statement in a string that can be sent to php. Does this seem reasonable? I’ll find out tomorrow. Best, Bill William Prothero http://earthlea

Re: SQL Help

2018-06-01 Thread prothero--- via use-livecode
Tnx for the input, folks. Yes, I want all of the columns. I could specify them each, because there are not many of them, but .. I’m done for the evening, and will try your suggestions first thing in the morning. Best, Bill William Prothero http://earthlearningsolutions.org > On Jun 1, 20

Re: SQL Help

2018-06-01 Thread Bob Sneidar via use-livecode
Even better! Bob S > On Jun 1, 2018, at 17:48 , Mike Bonner via use-livecode > wrote: > > if I understand correctly, and just off the top of my head, using "limit" > is one way to do this... > The sql pseudo code would be something like: select * from yourtable order > by iStoreGrp descendi

Re: SQL Help

2018-06-01 Thread Bob Sneidar via use-livecode
He wants all the columns I think. I suspect he will need a join on the same table. I'm too intoxicated to think about this, but I've done it before. Doesn't group by require that the columns be included in the select clause? Bob S > On Jun 1, 2018, at 17:43 , Paul Dupuis via use-livecode >

Re: SQL Help

2018-06-01 Thread Mike Bonner via use-livecode
if I understand correctly, and just off the top of my head, using "limit" is one way to do this... The sql pseudo code would be something like: select * from yourtable order by iStoreGrp descending where meterNum = 1 AND valveNum = 3 limit 1 This would grab all the rows, sort them by istoregrp and

Re: SQL Help

2018-06-01 Thread Paul Dupuis via use-livecode
Not tested, but: SELECT max(iStoreGrp) FROM valveFlowsA WHERE meterNum =1 AND valveNum =3 GROUP BY meternum, valvenum, iStoreGrp If my memory as I am falling asleep for the night serves me right. On 6/1/2018 8:31 PM, William Prothero via use-livecode wrote: > Folks: > Maybe someone can answer