Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. want one sql query...

want one sql query...

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestioncareer
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hi_everybody
    wrote on last edited by
    #1

    hi to all.... i have no so much experience in sql. one query i want may be its simple but still i want it. if there is table "EmpTbl" with fields empid,empname and salary. Then how i find the second max salary and second last salary of the Employee??? plz help me out ... thanks

    B C 2 Replies Last reply
    0
    • H hi_everybody

      hi to all.... i have no so much experience in sql. one query i want may be its simple but still i want it. if there is table "EmpTbl" with fields empid,empname and salary. Then how i find the second max salary and second last salary of the Employee??? plz help me out ... thanks

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      You'll get a lot of results if you search on google anyways.. Here the queries.. For second max.

      select MAX(salary) from EmpTbl where salary < (select MAX(salary) from EmpTbl)

      and For second min

      select Min(salary) from EmpTbl where salary > (select MIN(salary) from EmpTbl)

      Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0

      H 1 Reply Last reply
      0
      • H hi_everybody

        hi to all.... i have no so much experience in sql. one query i want may be its simple but still i want it. if there is table "EmpTbl" with fields empid,empname and salary. Then how i find the second max salary and second last salary of the Employee??? plz help me out ... thanks

        C Offline
        C Offline
        Crapaw45
        wrote on last edited by
        #3

        Here is one I did for freight_cost: You will need the second example. -- max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost -- 2nd max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost WHERE Freight_Cost NOT IN (SELECT MAX(Freight_Cost) FROM Product_Freight_Cost)

        H 1 Reply Last reply
        0
        • B Brij

          You'll get a lot of results if you search on google anyways.. Here the queries.. For second max.

          select MAX(salary) from EmpTbl where salary < (select MAX(salary) from EmpTbl)

          and For second min

          select Min(salary) from EmpTbl where salary > (select MIN(salary) from EmpTbl)

          Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0

          H Offline
          H Offline
          hi_everybody
          wrote on last edited by
          #4

          thanks a lot ok from this i will search on google instead of asking in forum.. but thanks a lot .....

          1 Reply Last reply
          0
          • C Crapaw45

            Here is one I did for freight_cost: You will need the second example. -- max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost -- 2nd max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost WHERE Freight_Cost NOT IN (SELECT MAX(Freight_Cost) FROM Product_Freight_Cost)

            H Offline
            H Offline
            hi_everybody
            wrote on last edited by
            #5

            thanks a lot...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups