Click here to Skip to main content
15,897,518 members
Home / Discussions / Database
   

Database

 
QuestionConvert SQL datetime to just date Pin
kozu31-May-07 5:29
kozu31-May-07 5:29 
AnswerRe: Convert SQL datetime to just date Pin
kubben31-May-07 5:36
kubben31-May-07 5:36 
GeneralRe: Convert SQL datetime to just date Pin
kozu31-May-07 6:01
kozu31-May-07 6:01 
AnswerRe: Convert SQL datetime to just date Pin
Shahil Shah31-May-07 6:13
Shahil Shah31-May-07 6:13 
GeneralRe: Convert SQL datetime to just date Pin
kozu31-May-07 6:24
kozu31-May-07 6:24 
GeneralRe: Convert SQL datetime to just date Pin
kozu31-May-07 6:36
kozu31-May-07 6:36 
GeneralRe: Convert SQL datetime to just date Pin
Shahil Shah31-May-07 6:38
Shahil Shah31-May-07 6:38 
AnswerRe: Convert SQL datetime to just date Pin
Michael Potter31-May-07 9:45
Michael Potter31-May-07 9:45 
Form your result set then use it as the source for the final query where you can format your data.

SELECT
    CONVERT(VARCHAR(20),OrderDate,101) AS OrderDate,
    TotalQty
FROM
    (
        SELECT  
            CAST(CONVERT(VARCHAR(20),OrderDate,101) AS DATETIME) AS OrderDate, 
            SUM(Qty) AS TotalQty
        FROM 
            Orders
        WHERE 
            CAST(CONVERT(VARCHAR(20),OrderDate,101) AS DATETIME) between '05/29/05' and '06/10/05'
        GROUP BY 
            CAST(CONVERT(VARCHAR(20),OrderDate,101) AS DATETIME)
    ) AS subqry
ORDER BY 
    OrderDate


Speed wise, I think kubben is correct. I would remove the CAST/CONVERT in the WHERE clause of the subquery with a little intelligent manipulation of the date ranges.
QuestionPlease Heeelp - connection error driving me crazy Pin
ComCoderCsharp31-May-07 4:11
ComCoderCsharp31-May-07 4:11 
AnswerRe: Please Heeelp - connection error driving me crazy Pin
Colin Angus Mackay31-May-07 4:17
Colin Angus Mackay31-May-07 4:17 
GeneralRe: Please Heeelp - connection error driving me crazy Pin
ComCoderCsharp31-May-07 5:07
ComCoderCsharp31-May-07 5:07 
GeneralRe: Please Heeelp - connection error driving me crazy Pin
Colin Angus Mackay31-May-07 8:13
Colin Angus Mackay31-May-07 8:13 
QuestionHow to check if a field already exists in a table Pin
SWDevil31-May-07 3:13
SWDevil31-May-07 3:13 
AnswerRe: How to check if a field already exists in a table Pin
Colin Angus Mackay31-May-07 4:14
Colin Angus Mackay31-May-07 4:14 
GeneralRe: How to check if a field already exists in a table Pin
SWDevil31-May-07 5:12
SWDevil31-May-07 5:12 
GeneralRe: How to check if a field already exists in a table Pin
Colin Angus Mackay31-May-07 8:14
Colin Angus Mackay31-May-07 8:14 
GeneralNormalising Single Table to Two Pin
Brady Kelly31-May-07 2:06
Brady Kelly31-May-07 2:06 
GeneralRe: Normalising Single Table to Two Pin
kubben31-May-07 2:34
kubben31-May-07 2:34 
GeneralRe: Normalising Single Table to Two Pin
Brady Kelly31-May-07 3:17
Brady Kelly31-May-07 3:17 
GeneralRe: Normalising Single Table to Two Pin
kubben31-May-07 3:23
kubben31-May-07 3:23 
GeneralRe: Normalising Single Table to Two Pin
Brady Kelly31-May-07 3:51
Brady Kelly31-May-07 3:51 
QuestionHow to Transfer SQl Database to a Cd and be Opened with SQl on the other side Pin
Vimalsoft(Pty) Ltd31-May-07 0:18
professionalVimalsoft(Pty) Ltd31-May-07 0:18 
AnswerRe: How to Transfer SQl Database to a Cd and be Opened with SQl on the other side Pin
Colin Angus Mackay31-May-07 1:40
Colin Angus Mackay31-May-07 1:40 
GeneralRe: How to Transfer SQl Database to a Cd and be Opened with SQl on the other side Pin
Vimalsoft(Pty) Ltd31-May-07 2:38
professionalVimalsoft(Pty) Ltd31-May-07 2:38 
GeneralRe: How to Transfer SQl Database to a Cd and be Opened with SQl on the other side Pin
Colin Angus Mackay31-May-07 4:15
Colin Angus Mackay31-May-07 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.