Forum Replies Created

Viewing 15 posts - 451 through 465 (of 2,007 total)

  • RE: newbie help pls

    prathibha_aviator (10/15/2012)


    For the same data Provide the SQL statement that would return every CustomerName and the count of orders they have ever placed.

    I have tried using the below code

    select...

  • RE: newbie help pls

    Here's how you should lay out your sample data: -

    CREATE TABLE Customer (CustomerID INT, CustomerName VARCHAR(200), Birthdate DATETIME);

    INSERT INTO Customer

    SELECT CustomerID,CustomerName,Birthdate

    FROM (VALUES(1,'John Doe','1/1/1970 08:31 AM'),(2,'Jane Doe','1/1/1971 01:18 PM'),

    ...

  • RE: Select Query to return all rows from one table

    Hello and welcome to SSC,

    If you could knock up some sample data and DDL scripts, then your expected results based on the sample data provided that would be extremely useful...

  • RE: Tempdb

    ramyours2003 (10/15/2012)


    How temp db worksin ? sql

    http://msdn.microsoft.com/en-us/library/ms190768.aspx

    http://www.youtube.com/watch?v=SvseGMobe2w

  • RE: How to populate end date based on start date

    Next record based on what? What is the ordering here?

    Sample data: -

    CREATE TABLE tmp_end_date(ID INT,tgs_rec_eff_dt DATETIME);

    INSERT INTO tmp_end_date

    SELECT ID, tgs_rec_eff_dt

    FROM (VALUES(1300505,'2012-08-01 15:57:15'),(1300505,'2012-08-01 15:55:16'),

    ...

  • RE: Find nearest date (looking in both directions)

    ChrisM@Work (10/12/2012)


    ps Craig, if you're in the Hob at 6.15, I'll buy you a pint 😉

    That the one on Broad Street? I'm in the process of moving house, we couldn't...

  • RE: Find nearest date (looking in both directions)

    ChrisM@Work (10/12/2012)


    It's a huge difference.

    I've just tried cheating by putting an ordinary index on startdate and the results are a little weird - possibly because my poor lappy is...

  • RE: Get count depending on specific criteria

    jon.wilson (10/12/2012)


    Cadavre, that is correct. I need to get the results

    Here's what I've been able to get so far. I can get the results by running one query...

  • RE: Help with Logic

    Wow. As Sean said, this is pretty weird as is always going to be out of sync.

    Because it's always going to be out of sync, you might as well do...

  • RE: Get count depending on specific criteria

    Lowell (10/12/2012)


    WITH myCTE ([Branch],[Year],[Count of All who failed],[Count of all right handed who failed])

    AS

    (

    SELECT 'Blue ',2012 , 120 , 87 UNION ALL

    SELECT 'Red ' ,2011 ,...

  • RE: T SQL Help - Comma separated numric value

    Jeff Moden (10/12/2012)


    Cadavre (10/12/2012)


    If you insist on doing it in the database layer, it can be achieved like this:

    Check again. OP's desired output doesn't actually have a comma as...

  • RE: Get count depending on specific criteria

    jon.wilson (10/12/2012)


    I need to get the counts for the number of records that meet specific criteria. Here's a scenario of what I need to accomplish. I can get...

  • RE: T SQL Help - Comma separated numric value

    Smash125 (10/12/2012)


    SELECT

    YEAR(OrderDate) ASOrderYear,

    SUM(CASE WHEN DATENAME(Q,OrderDate) =1 THEN TotalDue END)AS Q1,

    SUM(CASE WHEN DATENAME(Q,OrderDate) =2 THEN TotalDue END)AS Q2,

    SUM(CASE WHEN DATENAME(Q,OrderDate) =3 THEN TotalDue END)AS Q3,

    SUM(CASE WHEN DATENAME(Q,OrderDate) =4 THEN TotalDue...

  • RE: Find nearest date (looking in both directions)

    OK, I'm back in the office 🙂

    IF object_id('tempdb..#mySchedules') IS NOT NULL

    BEGIN

    DROP TABLE #mySchedules;

    END;

    SELECT TOP 1000000

    [id], DATEADD(DAY,((ABS(CHECKSUM(NEWID())) % 366) + 1),CAST('2010' AS DATE)) AS [recorddate],

    'schedule'+CAST(a.id AS VARCHAR(7))...

  • RE: Find nearest date (looking in both directions)

    I'm not back yet, but will be leaving soon as it looks like they're nearly finished so can test in 30 minutes or so. But could your code not be...

Viewing 15 posts - 451 through 465 (of 2,007 total)