Welcome, Guest. Please login or register.
September 09, 2010, 03:17:15 am
 
 PSOUG Forum Jump to:  

Home Help Search Login Register
PSOUG.org  |  General Category  |  PSOUG  |  Topic: Need a query « previous next »
Pages: [1] Print
Author Topic: Need a query  (Read 1411 times)
kirank05
Newbie
*
Posts: 1


View Profile
« on: April 20, 2009, 01:52:41 am »

Hi,

  I have a table contains 100 columns i need to write a query using group by and order by clauses.can you please help me in this.

Logged
Mike
Administrator
Hero Member
*****
Posts: 571



View Profile
« Reply #1 on: April 20, 2009, 08:22:29 am »

This is an example of syntax for the GROUP BY clause:

    SELECT column1, column2, ... column_n, aggregate_function (expression)
    FROM tables
    WHERE predicates
    GROUP BY column1, column2, ... column_n;


aggregate_function can be a function such as SUM, COUNT, MIN, or MAX.


Here's an example that uses the COUNT function:

SELECT department, COUNT(*) as "Number of employees"
FROM employees
WHERE salary > 25000
GROUP BY department;



Here's an example that uses the MIN function:

SELECT department, MIN(salary) as "Lowest salary"
FROM employees
GROUP BY department;
Logged
Pages: [1] Print 
PSOUG.org  |  General Category  |  PSOUG  |  Topic: Need a query « previous next »
Jump to:  


Login with username, password and session length
PSOUG.org - Need a query

SEO light theme by © Mustang forums. Powered by SMF 1.1.11 SMF © 2006-2008, Simple Machines LLC