2016年7月27日 星期三

Transact-SQL Reference documentation

overview page for this reference
https://msdn.microsoft.com/en-us/library/bb510741.aspx
ELEMENT EXPRESSION ROLE
SELECT (SELECT LIST) Define which coloum to return
Data 5 Data 6

SELECT
FROM
WHERE

  • where this condition is true. So we have a predicate statement as it's called

    • that filters the rows that come back. Now a lot
    GROUP BY
    • So I might have a GROUP BY clause where I'm grouping the results by
    • order date or order month. 
    • Not just the individual sales orders, but perhaps the totals for each month

    HAVING

    • And then I might want to filter those groups. So I might want to said HAVING
    • a count of orders of over a hundred. So only bring back the months where we sold
    • more than a hundred items.
    • So there's an additional HAVING clause. And then the final cause that you usually see in a
    (I'm only interest if somebody's got an order, so I want order ID greater than one,
    so I know there's more than one order on that date so it will
    clear out all the empty dates, like Saturdays and Sundays or whatever, and handle
    the dates where there is only one in fact.
    Oh, greater than one! So if there is only one, it wouldn't display that.)

    ORDER BY

    •  return the results in any particular order.



    SELECT CONVERT(nvarchar(30), OrderDate, 102) AS OrderDate
    FROM SalesLT.SalesOrderHeader;




      
          Syntax for CONVERT:  
    CONVERT ( data_type [ ( length ) ] , expression [ , style ] )  
    
    
    ,102 = Date and Time Styles

    沒有留言:

    張貼留言

    注意:只有此網誌的成員可以留言。