Created
April 3, 2012 13:42
-
-
Save meiwin/2292104 to your computer and use it in GitHub Desktop.
mig33 SQL (2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Write a SQL query that will result in full table scan. | |
select * | |
from transaction_journal | |
where ucase(Receiver) = 'FOO' | |
-- Write a SQL query that can introduce a deadlock. | |
select * | |
from transaction_journal | |
for update | |
; | |
-- Write a SQL query that returns the total amount received by a user named 'foo' from a user named 'bar' for all days between 2012-01-01 to 2012-01-31 | |
select sum(*) total | |
from transaction_journal | |
where receiver = 'foo' | |
and sender = 'bar' | |
and datecreated >= str_to_date('2012-01-01 00:00:00', '%Y-%m-%d %H:%i:%s') | |
and datecreated <= str_to_date('2012-01-31 23:59:59', '%Y-%m-%d %H:%i:%s') | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment