Jan 29, 2013; 09:52
Eric Browning
MySQL help
Ok this is driving me nuts. I have a mysql query that is refusing to work when the value in the where statement is changed. The total time adds up all of the event time fields logged per family_id. I've tried a few variations with DISTINCT but no luck so far. I'm trying to accomplish as much of this in SQL as possible just for efficiencies sake as I'm trying to not have to pull a few hundred records and then use lasso at add them all up. The rectype field is the parent or student type of record, p=parent, s=student.
SELECT family_id, school, SUM(TIME_TO_SEC(event_time)) AS 'total_time' FROM mytable WHERE school='VALUE1' GROUP BY family_id, rectype HAVING SUM(TIME_TO_SEC(event_time)) >= 3600 AND rectype LIKE 'p';
When it's value1 it works great, when it's value2 it returns no results and i have valid entried with value1, value2 and value3. Any help would be appreciated.
It should return with value1 based on the Having >= X seconds and being a parent record. I've tried putting the rectype='p' in the where clause but that bombs out everything.
family ID school total_time1234 VALUE1 10600...
OR with VALUE2 or VALUE3
family ID school total_time4321 VALUE2 324600 ...
Any help is appreciated, thanks.
--
Eric Browning
Systems Administrator
801-984-7623
Skaggs Catholic Center
Juan Diego Catholic High School
Saint John the Baptist Middle
Saint John the Baptist Elementary
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>