|
|
|
Monday, 26 December 2011 23:51 |
The DATEPART() function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc.
Syntax
DATEPART(datepart,date)
The following SELECT statement:
SELECT DATEPART(yyyy,OrderDate) AS OrderYear,
DATEPART(mm,OrderDate) AS OrderMonth,
DATEPART(dd,OrderDate) AS OrderDay,
FROM Orders
WHERE OrderId=1
OUTPUT
OrderYear OrderMonth OrderDay
2008 11 11
 Read more: |
|
|
Thursday, 22 December 2011 23:58 |
Select Case control structure is slightly different from the If....ElseIf control structure . The difference is that the Select Case control structure basically only make decision on one expression or dimension (for example the examination grade) while the If ...ElseIf statement control structure may evaluate only one expression, each If....ElseIf statement may also compute entirely different dimensions. Select Case is preferred when there exist many different conditions because using If...Then..ElseIf statements might become too messy.
The format of the Select Case control structure is show below:
Select Case expression
Case value1
Block of one or more VB statements
Case value2
Block of one or more VB Statements
Case value3
.
Case Else
Block of one or more VB Statements
End Select
Example 1
Select Case grade
Case "A"
result.Caption="High Distinction"
Case "A-"
result.Caption="Distinction"
Case "B"
result.Caption="Credit"
Case "C"
result.Caption="Pass"
Case Else
result.Caption="Fail"
End Select
Example 2
Select Case mark
Case Is >= 85
comment.Caption = "Excellence"
Case Is >= 70
comment.Caption = "Good"
Case Is >= 60
comment.Caption = "Above Average"
Case Is >= 50
comment.Caption = "Average"
Case Else
comment.Caption = "Need to work harder"
End Select
Example 3
Select Case mark
Case 0 to 49
comment.Caption = "Need to work harder"
Case 50 to 59
comment.Caption = "Average"
Case 60 to 69
comment.Caption = "Above Average"
Case 70 to 84
comment.Caption = "Good"
Case Else
comment.Caption = "Excellence"
End Select
 Read more: |
|
Friday, 22 April 2011 04:24 |
Entry.where(:id => Entry.select('max(id) id').arel).to_sql
=> "SELECT \"entries\".* FROM \"entries\" WHERE (\"entries\".\"id\" IN (SELECT max(id) id FROM \"entries\"))"
 Read more: |
|
|
Monday, 20 December 2010 10:52 |
|
Well this is a nice early stocking stuffer! Now through 11:59pm (PST) on December 22nd, Amazon's giving you free one-day shipping on certain electronics, software, and video games. After you add a qualifying item to your cart, select One-Day Shipping at checkout and they'll apply the discount. The deal also applies to select jewelry, movies, musical instruments, and more, but be sure to double-check that your order qualifies here. For last-minute shoppers like, I dunno, all of us? The checkout line at Amazon's way shorter than the ones at Montgomery Mall. [Amazon] More »
    Read more: |
|
|
|
|
|
|
|