Reputation
2,579
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
10 28
Newest
 Good Answer
Impact
~108k people reached

3h
comment Compare values between columns in different tables
Sorry, it's still a little unclear. What does "action that relies on code side" mean? Do you mean the client-side code? Also, do you want to perform the action for every row where MAX(_sync_history.sync_time) > _sync_pdone.sync_time or just if there is at least one such row? So far it seems to me you could just count the rows in _sync_pdone where sync_time is less than the required value and return the result to the client. And your client side would consume the result and decide what to do (the IF condition would be in your client code).
6h
awarded  Good Answer
8h
comment How to tune a stored procedure that is fast on test data but slow in production
simple-talk.com/sql/sql-training/…
8h
comment How to check if all days of the month are in the database
Even if I could help you with a SQL query (of which I'm not sure), you would probably still need help integrating the query into your PHP script. However, it looks like you are using some framework which allows you to build database queries in a different way (I'm talking about this fragment: $attendance = DB::table('wys_teacherattendances') ->where('t_amonth', $amonth) ->where('t_ayear', $ayear) ->get(); – that's not SQL). I'm not familiar with that framework. Overall, it seems to me your question needs to be migrated to Stack Overflow, where it would be a better fit.
9h
comment How to check if all days of the month are in the database
I made some assumptions while editing your post. Please review, and feel free to edit further or roll back as necessary.
9h
revised How to check if all days of the month are in the database
improved formatting, grammar, rephrased for clarity
10h
comment How to tune a stored procedure that is fast on test data but slow in production
So is the gist of your post "How to tune a stored procedure that is fast on test data but slow in production"?
11h
revised How to store data where various subcategories have specific columns?
replaced a tag, corrected formatting and grammar, rephrased the title and some bits for clarity
11h
comment HAVING Clause syntax question
Your SUM expression's got a redundant ) (the one after AND date2). Otherwise it's fine (syntactically anyway).
11h
comment Compare values between columns in different tables
PERFORM SOME ACTION HERE – What kind of action do you have in mind? Is this something to do with the _sync_pdone row whose sync_time you are comparing to MAX(_sync_history.sync_time)?
11h
reviewed Edit Deleting near duplicates based on one varchar field
11h
revised Deleting near duplicates based on one varchar field
Improved formating, added a tag
11h
answered Deleting near duplicates based on one varchar field
12h
answered Extract four digits from a column by regexp
1d
comment Word for describing how normal (technical term) a database is
If you are looking for a noun phrase, perhaps "degree of normalisation" would fit.
2d
comment Creating a trigger to update field in 1 table based on values in another table using data in multiple rows
All right, but have you tried looking for those points independently and then putting things together yourself? Even though you are a novice in SQL, you will likely find the learning process more effective if you take an active part in it. Besides, hardly anyone likes doing someone else's work for free. The "payment" in this case is showing your own effort.
2d
comment How to get Business days per month between two dates?
This is really something that's easy to google. Of the two questions suggested by @MattD, for instance, the SQL Server one was the top result for me when I googled for count business days sql server.
2d
comment Creating a trigger to update field in 1 table based on values in another table using data in multiple rows
DBA.SE works best if the problem is as specific as possible. What you have here, without any further clarification, sounds like at least three problems: (1) how to declare a trigger, (2) how to reference the affected rows in a trigger, (3) how to update a table from another table. So which of those do you need an answer for?
2d
comment How to write a query that counts rows by date?
Wouldn't it be better to use CURDATE() instead of NOW()? At least if datum is a DATE.
Jul
31
comment Minimum value on most recent date per account MS ACCESS SQL
Actually this will not compile in SQL Server, unless you specify an alias for the subselect.