Forum Replies Created

Viewing 15 posts - 556 through 570 (of 3,544 total)

  • RE: SP for Difference between Dates in Years.Days format

    SELECT CAST(

    CASE SIGN(DATEPART(dy,@Enddate)-DATEPART(dy,@Startdate))

    WHEN 0 THEN DATEDIFF(year,@Startdate,@Enddate)

    WHEN 1 THEN DATEDIFF(year,@Startdate,@Enddate)+(DATEPART(dy,@Enddate)-DATEPART(dy,@Startdate))/1000.0

    ELSE (DATEDIFF(year,@Startdate,@Enddate)-1)+(DATEDIFF(day,DATEADD(year,DATEDIFF(year,@Startdate,@Enddate)-1,@Startdate),@Enddate))/1000.0

    END as decimal(9,3))

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Get ProductConfig With Lowest Prise

    sm_iransoftware (2/17/2015)


    Thank you all

    And

    Thank you David Burrows

    I didnot Know Row_Number() Befor this.

    Actually ROW_NUMBER was introduced with 2005, you might want to check out the other windowing functions as well, 2014...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Get ProductConfig With Lowest Prise

    Using row number

    SELECT ProductId,ProductConfigId,Amount AS [MinPrice],HasGift

    FROM (SELECT p.ID AS [ProductId],c.ID AS [ProductConfigId],a.Amount,c.HasGift,

    ROW_NUMBER() OVER (PARTITION BY p.ID ORDER BY a.Amount ASC) AS [RowNum]

    FROM dbo.TBL_Product p

    JOIN dbo.TBL_ProductConfig c ON c.ProductId = p.ID

    JOIN...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Showing Child values in one column from the same table

    CREATE TABLE dbo.Person (PersonID int,FirstName varchar(20),LastName varchar(20))

    CREATE TABLE dbo.Relation (RelationID int,BossID int,SlaveID int)

    INSERT dbo.Person VALUES (1,'Bob','Patel'),(2,'Lun','Smith'),(3,'Julie','Taylor'),(4,'Chris','Pain'),(5,'Joe','Bloggs')

    INSERT dbo.Relation VALUES (1234,1,3),(321,3,3),(231,1,5)

    SELECT p.PersonID,p.FirstName,p.LastName,

    STUFF((SELECT ',' + Name

    FROM (SELECT DISTINCT s.FirstName + ' ' +...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How to return top n and sum up the rest

    Just for fun 😀

    SELECT ISNULL(Category,'Total') AS [Category],SUM(Column1) AS [Total]

    FROM MyTable

    GROUP BY Category

    WITH ROLLUP

    HAVING Category IS NULL OR Category IN ('Category1','Category2','Category3','Category4')

    ORDER BY GROUPING(Category) ASC,Category ASC

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How to return top n and sum up the rest

    Hint: Use CASE statement for Category and use it in GROUP BY

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Condtional action.

    Glad you solved it 🙂

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Condtional action.

    Ooops my bad, I was testing using Value

    Why are you using UniqueName, is the report using a cube?

    If you put the expression Nazwa pomiaru.UniqueName in another textbox do you get...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Condtional action.

    I'm on SQL2008R2 and it work for me

    What version are you on?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Won't convert to decimal

    OK but like I said it stops inserting before the first record and I presume it's to do with the characters in the field of the first row.

    But we cannot...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Won't convert to decimal

    Check the XML for hidden characters as this would stop the implicit decimal conversion

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Condtional action.

    Try

    Switch(Fields!Nazwa_pomiaru.UniqueName = "regulacji", "IRSRZGD", Fields!Nazwa_pomiaru.UniqueName = "tryb", "IRSRZGD", True, Nothing)

    although I think this will work as well

    IIf(Fields!Nazwa_pomiaru.UniqueName = "regulacji" OR Fields!Nazwa_pomiaru.UniqueName = "tryb", "IRSRZGD", Nothing)

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: ssrs expression to find count of records which falls beween two dates

    Sum(IIf(DateDiff(DateInterval.Day,Fields!SubmittedDate.Value,Today)>=31 AND DateDiff(DateInterval.Day,Fields!SubmittedDate.Value,Today)<=60,1,0))

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Anyone tried "DBA Job Interview Question & Answer Kit"?

    Jeff Moden (1/31/2015)


    It broke my heart during an interview the other day. Some guy had all the right qualities to be a perfect fit for the team but we...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Need assistance with Update Query

    Brian Hibbert (2/1/2015)


    Try using the FROM clause in the UPDATE statement instead of a select. The right side of the SET = should be your CASE statement, but you...

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 15 posts - 556 through 570 (of 3,544 total)