TechSapphire Wednesday, 2018-05-23, 4:00 PM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • Main » Files » Database

    Select Alternate Row SQL Server
    2012-09-03, 9:22 PM
    Select Alternate Row SQL Server

    Their are many approaches to get alternate record from SQL server database table. Here i have discussed 2 approaches
    1. Complex Query
    2. Using Views

    Complex Query: SELECT * from (SELECT ROW_NUMBER() OVER(ORDER BY Employee_id) as RowNumber, * from employees) T where t.RowNumber%2=0

    Using Views:
    CREATE VIEW with_rownumber
    as
    SELECT ROW_NUMBER() OVER(ORDER BY Employee_id) as RowNumber,* from employees;

    SELECT * from with_rownumber where RowNumber%2=0

    The approach preferred here is using VIEW because:
    1. Easy to understand.
    2. In future if you need to perform any operation related to RowNumber then you don't need to create another complex query. You could use view having rownumber column in it.


    Category: Database | Added by: Admin | Tags: SQL Server, even, sql, Odd, row, ROW NUMBER, Alternate, select
    Views: 1442 | Downloads: 0 | Comments: 10 | Rating: 0.0/0
    Total comments: 1
    1  
    Ο/Η Dan λέει:Dear Admin,some friends alrteed us your site used all our photos (that we posted in another amateur site) without our permissions.this is the gallery Please remove them!!!Probably you didn’t know it and maybe a very bad member of your site used it without you know it, but me and my wife don’t allow this.We wait your reply as soon as possible!Thanks for understandingD&A

    Only registered users can add comments.
    [ Registration | Login ]
    Categories
    Programming [3]
    .Net solution,.net project,vb project,vb,c#,.net,c language,c++,projects,project,college project,html template,free template,java
    .Net [0]
    .Net program,vb.net,c#.net,asp.net,projects,.net project,programming solution,free projects
    Mystic Programs [0]
    programming challenges,computer quiz question,secret program
    Security [0]
    Security,window security,web security,web vulnerabilities,virus,virus programming,software security,validation
    Google [0]
    Google search,Google tricks,restrict Google search,Free book search,search Ftp directly,search directory,search direct link rapidshare,search torrent directly
    Project [0]
    College projects,free project,c language project,vb project,vb.net project,.net project,c# project,html project
    Video Tutorial [2]
    Free Video Tutorial
    Database [1]
    SQL Server
    Copyright MyCorp © 2018