Loading ...
Sorry, an error occurred while loading the content.

{Query} 2nd max salary from table

Expand Messages
  • satheesh sankar
    Hi, Can u pls tell me how to get 2nd max salary from the table using mysql query? thanks, satheesh ... Get the freedom to save as many mails as you wish. Click
    Message 1 of 10 , Sep 29, 2007
    • 0 Attachment
      Hi,

      Can u pls tell me how to get 2nd max salary from the table using mysql query?


      thanks,
      satheesh


      Get the freedom to save as many mails as you wish. Click here to know how.
    • bhavna_coolinus
      get the distinct table data in assending order of salary and then fetch array(1) from that u will get sedong most record... Thanks, Bhavna. ... mysql query?
      Message 2 of 10 , Sep 30, 2007
      • 0 Attachment
        get the distinct table data in assending order of salary and then
        fetch array(1) from that u will get sedong most record...

        Thanks,
        Bhavna.

        --- In php4india@yahoogroups.com, satheesh sankar <ss_aguner@...>
        wrote:
        >
        > Hi,
        >
        > Can u pls tell me how to get 2nd max salary from the table using
        mysql query?
        >
        >
        > thanks,
        > satheesh
        >
        >
        > ---------------------------------
        > Get the freedom to save as many mails as you wish. Click here to
        know how.
        >
      • jaave_d@indiatimes.com
        Query is = Select max(salary) from table1 where salary != (Select max(salary) from table1) ;
        Message 3 of 10 , Oct 1, 2007
        • 0 Attachment
          Query is = "Select max(salary) from table1 where salary != (Select max(salary) from table1)";


          ************************************************************************
          Javed Shaikh
          09226747220
          Web Development(IT)
          Centre For Monitoring Indian Economy Pvt Ltd
          Apple Heritage, Andheri(E) - Mumbai
          ************************************************************************

          ----- Original Message -----
          From: satheesh sankar <ss_aguner@...>
          To: php4india@yahoogroups.com
          Sent: Sat, 29 Sep 2007 15:28:56 +0530 (IST)
          Subject: [php4india] {Query} 2nd max salary from table

          Hi,

          Can u pls tell me how to get 2nd max salary from the table using mysql query?


          thanks,
          satheesh


          ---------------------------------
          Get the freedom to save as many mails as you wish. Click here to know how.

          --
          My life has changed. What about yours?
          Log on to the new Indiatimes Mail and Live out of the Inbox!
        • darshit pandya
          I think this would work better.for Mysql select distinct(salary) from salary order by salary desc LIMIT 1,1 Darshit jaave_d@indiatimes.com wrote:
          Message 4 of 10 , Oct 1, 2007
          • 0 Attachment
            I think this would work better.for Mysql


            select distinct(salary) from salary order by salary desc LIMIT 1,1

            Darshit


            jaave_d@... wrote:
            Query is = "Select max(salary) from table1 where salary != (Select max(salary) from table1)";


            ************ ********* ********* ********* ********* ********* ********* ******
            Javed Shaikh
            09226747220
            Web Development( IT)
            Centre For Monitoring Indian Economy Pvt Ltd
            Apple Heritage, Andheri(E) - Mumbai
            ************ ********* ********* ********* ********* ********* ********* ******

            ----- Original Message -----
            From: satheesh sankar <ss_aguner@yahoo. co.in>
            To: php4india@yahoogrou ps.com
            Sent: Sat, 29 Sep 2007 15:28:56 +0530 (IST)
            Subject: [php4india] {Query} 2nd max salary from table

            Hi,

            Can u pls tell me how to get 2nd max salary from the table using mysql query?


            thanks,
            satheesh


            ------------ --------- --------- ---
            Get the freedom to save as many mails as you wish. Click here to know how.

            --
            My life has changed. What about yours?
            Log on to the new Indiatimes Mail and Live out of the Inbox!


            Building a website is a piece of cake.
            Yahoo! Small Business gives you all the tools to get online.

          • Naga lingam
            Hi Satheesh, Try this $query = select distinct(salary) from order by salary desc limit 1,1 ; Thanks, Naga satheesh sankar
            Message 5 of 10 , Oct 2, 2007
            • 0 Attachment
              Hi Satheesh,
               
              Try this
              $query = "select distinct(salary) from <table> order by salary desc limit 1,1";
               
              Thanks,
              Naga
               


              satheesh sankar <ss_aguner@...> wrote:
              Hi,

              Can u pls tell me how to get 2nd max salary from the table using mysql query?


              thanks,
              satheesh

              Get the freedom to save as many mails as you wish. Click here to know how.


              Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.

            • Jeyaseelan
              hi, u can use this query to find 2nd max salary select max(sal) from salary where sal not in (select max(sal) from salary) order by sal desc regards,
              Message 6 of 10 , Oct 2, 2007
              • 0 Attachment
                hi,
                u can use this query to find 2nd max salary

                select max(sal) from salary
                where sal not in (select max(sal) from salary)
                order by sal desc

                regards,
                Jeyaseelan

                bhavna_coolinus <bhavna_coolinus@...> wrote:
                get the distinct table data in assending order of salary and then
                fetch array(1) from that u will get sedong most record...

                Thanks,
                Bhavna.

                --- In php4india@yahoogrou ps.com, satheesh sankar <ss_aguner@. ..>
                wrote:
                >
                > Hi,
                >
                > Can u pls tell me how to get 2nd max salary from the table using
                mysql query?
                >
                >
                > thanks,
                > satheesh
                >
                >
                > ------------ --------- --------- ---
                > Get the freedom to save as many mails as you wish. Click here to
                know how.
                >



                Download prohibited? No problem. CHAT from any browser, without download.

              • prathi_chakri
                Hi, I think this query is suitable for u to select second max salary. SELECT salary from tblname where salary
                Message 7 of 10 , Oct 4, 2007
                • 0 Attachment
                  Hi,
                  I think this query is suitable for u to select second max salary.
                  SELECT salary from tblname where salary<(SELECT MAX(salary) FROM
                  tblname LIMIT1);
                • prathi_chakri
                  Hi, I think this query is suitable for u. SELECT salary FROM tblname where salary
                  Message 8 of 10 , Oct 4, 2007
                  • 0 Attachment
                    Hi,
                    I think this query is suitable for u.
                    SELECT salary FROM tblname where salary<(SELECT MAX(salary) FROM
                    tblname LIMIT1)
                  • D.S. JOSEPH
                    Dear Prathi, The SQL will not return the second max. The problem has already been solved by the reply given in the group: SELECT max(salary) FROM tblname
                    Message 9 of 10 , Oct 4, 2007
                    • 0 Attachment

                      Dear Prathi,

                       

                      The SQL will not return the second max.  The problem has already been solved by the reply given in the group:

                      SELECT max(salary) FROM tblname WHERE salary < (SELECT MAX(salary) FROM
                      tblname);

                       

                      Regards,

                      Joseph

                       



                      ----- Original Message ----
                      From: prathi_chakri <prathi_chakri@...>
                      To: php4india@yahoogroups.com
                      Sent: Thursday, October 4, 2007 2:11:51 PM
                      Subject: [php4india] Re: {Query} 2nd max salary from table

                      Hi,
                      I think this query is suitable for u to select second max salary.
                      SELECT salary from tblname where salary<(SELECT MAX(salary) FROM
                      tblname LIMIT1);




                      Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.
                    • Udaya kumar
                      Hi, Somebody has asked how to take 2nd maximum salary from the table. Follow the below query. It is used for Nth Maximum Salary from the table. SELECT * FROM
                      Message 10 of 10 , Oct 5, 2007
                      • 0 Attachment
                        Hi,

                        Somebody has asked how to take 2nd maximum salary from the table. Follow the below query. It is used for Nth Maximum Salary from the table.

                        SELECT * FROM employee E1 WHERE (N-1) = (SELECT COUNT(DISTINCT(E2.empsalary)) FROM employee E2 WHERE e2.empsalary > E1.empsalary)

                        following for taking the 2nd maximum salary:

                        SELECT * FROM employee E1 WHERE (2-1) = (SELECT COUNT(DISTINCT(E2.empsalary)) FROM employee E2 WHERE e2.empsalary > E1.empsalary)


                        This works in any RDBMS.

                        Regards
                        Udayakumar Sarangapani
                        Sr. PHP Developer
                        CompIndia Infotech Pvt. Ltd.
                        Chennai.


                        ----- Original Message ----
                        From: D.S. JOSEPH <joseph_ds@...>
                        To: php4india@yahoogroups.com
                        Sent: Friday, October 5, 2007 10:26:08 AM
                        Subject: Re: [php4india] Re: {Query} 2nd max salary from table

                        Dear Prathi,

                         

                        The SQL will not return the second max.  The problem has already been solved by the reply given in the group:

                        SELECT max(salary) FROM tblname WHERE salary < (SELECT MAX(salary) FROM
                        tblname);

                         

                        Regards,

                        Joseph

                         



                        ----- Original Message ----
                        From: prathi_chakri <prathi_chakri@ yahoo.com>
                        To: php4india@yahoogrou ps.com
                        Sent: Thursday, October 4, 2007 2:11:51 PM
                        Subject: [php4india] Re: {Query} 2nd max salary from table

                        Hi,
                        I think this query is suitable for u to select second max salary.
                        SELECT salary from tblname where salary<(SELECT MAX(salary) FROM
                        tblname LIMIT1);




                        Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.



                        Pinpoint customers who are looking for what you sell.
                      Your message has been successfully submitted and would be delivered to recipients shortly.