Popular Posts
jQuery : post/get using data() as param object <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html... android.intent.action.SCREEN_ON & android.intent.action.SCREEN_OFF First, I've tried create a receiver to receive screen on/off and register receiver on AndroidManifest.xml like below, but unfortunately ... runas RUNAS 使用方法: RUNAS [ [/noprofile | /profile] [/env] [/netonly] ] /user: program RUNAS [ [/noprofile | /profile] [/env] [/netonly] ...
Blog Archive
Stats
Join related table and count rows or sum
sql server 2005
count rows:
SELECT * FROM Table1
LEFT JOIN
    (SELECT Level1ID, COUNT(Level2ID) AS Total FROM Table2 GROUP BY Level1ID) AS RelatedTable
ON
    Table1.Level1ID = RelatedTable.Level1ID
WHERE
    SomeColumn = Something
count sum:
SELECT * FROM Table1
LEFT JOIN
    (SELECT Level1ID, SUM(Bonus) AS TotalBonus FROM Table2 GROUP BY Level1ID) AS RelatedTable
ON
    Table1.Level1ID = RelatedTable.Level1ID
WHERE
    SomeColumn = Something