Forum Replies Created

Viewing 15 posts - 91 through 105 (of 499 total)

  • RE: SUM WITHIN SUM

    I missed out the original grouping. :doze:

    ;WITH IntermediateQRY AS (

    SELECT DR_DCATCD,

    SUM(DR_DQTY)-SUM(POUT_QTY) AS IntermediateQTY,

    SUM(DR_DQTY*DR_DUPRICE) AS AMT

    FROM DRDTL

    INNER JOIN

    POUT_DTL

    ON DRDTL.DR_DICODE=POUT_DTL.POUT_BC

    WHERE DR_DDATE BETWEEN #6/1/2009# AND #6/30/2009#

    AND DR_DSTORE IN('342','338','333','302','315','303','312','332','316','325','339','129','217','128')

    GROUP BY DR_DCATCD

    )

    SELECT DR_DCATCD,

    ...

  • RE: SUM WITHIN SUM

    Try this

    ;WITH IntermediateQRY AS (

    SELECT DR_DCATCD,

    SUM(DR_DQTY)-SUM(POUT_QTY) AS IntermediateQTY,

    SUM(DR_DQTY*DR_DUPRICE) AS AMT

    FROM DRDTL

    INNER JOIN

    POUT_DTL

    ON DRDTL.DR_DICODE=POUT_DTL.POUT_BC

    WHERE DR_DDATE BETWEEN #6/1/2009# AND #6/30/2009#

    AND DR_DSTORE IN('342','338','333','302','315','303','312','332','316','325','339','129','217','128')

    GROUP BY DR_DCATCD

    )

    SELECT SUM(IntermediateQTY) AS QTY,

    ...

  • RE: temporary tables or table variable for this context ?

    There are ways of joining the output of a stored procedure to another table. One way would be to use ##Temp tables

    Another would be to use INSERT ... EXEC...

  • RE: SUM WITHIN SUM

    In SQL Server I get this error

    Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

    So I would guess its not possible in Access either.

  • RE: temporary tables or table variable for this context ?

    It depends what you want.

    Do you want each session's data to be separate. If so use @Table variables or #Temp tables in the procedure - they are isolated to...

  • RE: Elementary Key Attributes

    I think that volcanic air is getting to you Tom, This question is way over most of our heads - a really hard question. No amount of googling seemed...

  • RE: PageBreaks

    Normally print formatting would not be done in the SQL. SQL would be used simply to select the data and another program would apply the print formatting to suit...

  • RE: Help me with a code, please

    Bouben (12/7/2011)


    I need to understand two things in this part of the code. What does those red expressions in quotes mean and what does T.N mean? Probably stupid questions but...

  • RE: DATETIME 1

    First I got 53,30,1,32 - but soon realised you're using an ambiguous date format.

    Thanks for the question:

    Week 53 is quite a common occurrance where I work, so it...

  • RE: Help me with a code, please

    Bouben (12/6/2011)


    Tom Brown (12/6/2011)


    There will be a much simpler and faster way of doing this problem without using LOOPs. If you are interested I can sort out a...

  • RE: Help me with a code, please

    For your assignment you need to replace the Oracle part

    FOR Emp IN (SELECT * FROM Employee)

    LOOP

    WITH a CURSOR in SQL SERVER

    DECLARE @EmpID INT;

    DECLARE cur_Emp CURSOR FOR (SELECT Employee_ID FROM Employee)

    OPEN...

  • RE: See overview of schedules

    In MSDB there are sysjobs and sysjobschedules tables.

    I think there are others too. Search these names for examples of job schedule listings.

  • RE: Complex joins

    I had never heard of Nested Joins, so learned something today.

    However my method of getting the right answer was to use the execution plans. One execution plan exactly matched...

  • RE: Evaluating PIN codes

    Regardless of whether you should be using 4-digit PINs at all, Here is how I would approach the problem. Since there are only 10,000 possible PINs - I would...

  • RE: Evaluating PIN codes

    Some hints to get you started.

    Convert the PIN to text

    Use CHARINDEX to compare "78901234567890123", see if the PIN is contained in that

    Use a Tally Table to see if Char N+1...

Viewing 15 posts - 91 through 105 (of 499 total)