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

Re: [SQLQueriesNoCode] Aggegate function and groupby question.

Expand Messages
  • Charles Carroll
    ... Insert Into tableNameA ([FieldName1],[FieldName2]) Select [FieldName1b],[FieldName2b] from TableNameB ... TOP 1 and ORDER BY DESC will get your group
    Message 1 of 2 , Feb 29, 2012
    • 0 Attachment
      On Wed, Feb 29, 2012 at 4:20 AM, sapana <sapana_de@...> wrote:

      > **
      >
      >
      > Hi,
      >
      > I am new to this group and SQL as well... so I am trying out basic
      > commands..I have few questions if someone can answer them.
      >
      > 1. Can we Insert multiple rows in one query without using select command ?
      > I want to insert multiple rows in one query.
      >

      Insert Into tableNameA ([FieldName1],[FieldName2])
      Select [FieldName1b],[FieldName2b] from TableNameB


      >
      > 2. I wanted to get Name and max salary in one query.
      > select Max(salary) from employees will give me max salary
      > select Name, Max(salary) from employees groupby name : gives me names of
      > all employees with their max salary... I am not sure what column name to
      > groupby to get one single name with max salary.
      >

      TOP 1 and ORDER BY DESC will get your group query to one maximum answer


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.