Getting Started with Adobe After Effects - Part 6: Motion Blur
Ask
Ask questions, discuss or help others by answering
Related Posts · View All
SQL Server 146
TSQL 76
SSRS 71
SSIS 68
XML 57

Top Categories · View All
SQL Server 146
TSQL 76
SSRS 71
SSIS 68
XML 57

Problem with query

Nov 9 2012 12:00AM by gogul   

Hi,
I would like to write CTE Query to get expected results.
Here are the table and expected results.
1)

    declare @t table(zid int,dok varchar(100),stawka int)
    insert into @t values
    (1,'333',10),
    (2,'333',10),
    (3,'333',20),
    (4,'333',30),
    (5,'333',30)
Expected result:

    dok stawka
    333 10 --max z zid 1,2
    333 20
    333 30 --min z zid 4,5
2)
    
    declare @t table(zid int,dok varchar(100),stawka int)
    insert into @t values
    (1,'333',10),
    (2,'333',10),
    (3,'333',20),
    (4,'333',20),
    (5,'333',30)
Expected result:

    dok stawka
    333 10 --max z zid 1,2
    333 20 --min z zid 3,4
    333 30
3)

    declare @t table(zid int,dok varchar(100),stawka int)
    insert into @t values
    (1,'333',10),
    (2,'333',10),
    (3,'333',20),
    (4,'333',30),
    (5,'333',10)
Expected result:

    dok stawka
    333 10 --max z zid 1,2
    333 20
    333 30
    333 10
Regards 
Gogul

Submitted under: Microsoft SQL Server · TSQL ·  ·  · 


gogul
132 · 1% · 397

2 Replies

  • code

    select dok,stawka,min(zid),max(zid) from
    (select *,zid - row_number() over(partition by dok,stawka order by zid) grp from @t) x
    group by dok,stawka,grp
    order by min(zid)
    
    commented on Feb 7 2013 3:55AM
    Leszek Gniadkowski
    8 · 18% · 5729
  • THX for Answer:)

    commented on Mar 31 2013 7:36AM
    gogul
    132 · 1% · 397

Your Reply


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]