$("*").filter(function() { return $(this).css("display") == "none" }).css("display","")
Wednesday, February 29, 2012
Sunday, February 26, 2012
Mobile UI Frameworks (popular ones as of today..Feb 2012)
JQuery Mobile
http://jquerymobile.com
Sencha Touch
http://www.sencha.com/products/touch
JqTouch
http://jqtouch.com
Kendo UI
http://www.kendoui.com/mobile.aspx
http://jquerymobile.com
Sencha Touch
http://www.sencha.com/products/touch
JqTouch
http://jqtouch.com
Kendo UI
http://www.kendoui.com/mobile.aspx
Tuesday, February 21, 2012
Sunday, February 19, 2012
Sunday, February 12, 2012
More examples using Correlated Subquery
More examples using Correlated Subquery-
In my opinion, although Method 1 has the extra select statement at the top, it conveys the logic of the query better than Method 2.
In Method 2, we basically have pushed the 'join' statement inside the outer query.
SELECT
A.*, Challenge.*
FROM
(SELECT CE1.Challenge_ID,Question1,Question2,Question3,Question4,Question5,Question6
FROM Challenge_Enter as CE1
WHERE CE1.ID =
(SELECT max(CE2.ID)
From Challenge_Enter as CE2
WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0)
) A
INNER JOIN
Challenge
on A.Challenge_ID = Challenge.ID
SELECT Challenge.*,CE1.Challenge_ID,Question1,Question2,Question3,Question4,Question5, Question6
FROM Challenge_Enter as CE1
INNER JOIN Challenge on CE1.Challenge_ID = Challenge.ID
WHERE CE1.ID =
(SELECT max(CE2.ID)
From Challenge_Enter as CE2
WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0)
In my opinion, although Method 1 has the extra select statement at the top, it conveys the logic of the query better than Method 2.
In Method 2, we basically have pushed the 'join' statement inside the outer query.
Method 1:
SELECT
A.*, Challenge.*
FROM
(SELECT CE1.Challenge_ID,Question1,Question2,Question3,Question4,Question5,Question6
FROM Challenge_Enter as CE1
WHERE CE1.ID =
(SELECT max(CE2.ID)
From Challenge_Enter as CE2
WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0)
) A
INNER JOIN
Challenge
on A.Challenge_ID = Challenge.ID
Method 2:
SELECT Challenge.*,CE1.Challenge_ID,Question1,Question2,Question3,Question4,Question5, Question6
FROM Challenge_Enter as CE1
INNER JOIN Challenge on CE1.Challenge_ID = Challenge.ID
WHERE CE1.ID =
(SELECT max(CE2.ID)
From Challenge_Enter as CE2
WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0)
Correlated Subquery, Common Table Expression example
Here are 3 different ways to write the same query.
The difference between using Self-Join method, CTE method, and Correlated Subquery method --> in Correlated Subquery method, I could use the ID column (which is the primary key column); but we cannot use ID in Group By (since it will be unique for each row), so we cannot use it in the Self-Join & CTE methods
Hence, while writing Correlated Subqueries, we 'probably' have to focus on this --> returning the Primary Key of the outer query's table from the subquery
(This has to be verified by looking at examples)
From the table Challenge_Enter,
find out all the details of the latest Challenge to which the Customer 1123607 has entered into.
Self-Join
---------
SELECT
xx.*, Question1, Question2, Question3, Question4, Question5, Question6
FROM
Challenge_Enter yy
INNER JOIN
(SELECT
CustomerID, Challenge_Id, max(EnterDate) AS EnterDate
FROM
Challenge_Enter
WHERE
customerid = 1123607 AND Challenge_ID > 0
GROUP BY
Challenge_Id, CustomerID
) xx
ON yy.Challenge_ID = xx.Challenge_ID
WHERE
yy.EnterDate = xx.EnterDate
Common Table Expression
-----------------------
WITH
max_entries (Challenge_ID, maxEnterDate) As
(
SELECT
Challenge_id, max(EnterDate) maxEnterDate
from
Challenge_Enter
where CustomerID = 1123607 AND Challenge_ID > 0
group BY
Challenge_ID
)
SELECT
*
FROM
max_entries
INNER JOIN
Challenge_Enter
ON
max_entries.Challenge_ID = Challenge_Enter.Challenge_ID AND
max_entries.maxEnterDate = Challenge_Enter.EnterDate
Correlated Subquery
-------------------
SELECT
Challenge_ID,Question1,Question2,Question3,Question4,Question5,Question6
FROM
Challenge_Enter as CE1
WHERE
ID = (SELECT max(CE2.ID) From Challenge_Enter as CE2 WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0 )
Subscribe to:
Posts (Atom)