Show Query Output in Single Row

Posted on 2011-10-03
Last Modified: 2012-05-12
I have a table that records each time the price of a job is created or subsequently amended, eg:

Id      JobId       Rate
1       100123     90.00
2       100123     85.00
3       100123     75.00
4       100124     80.00
5       100124     85.00
6       100125     90.00

I want to report on is the highest and lowest rates per job, so:

Required output:

JobId        HighestRate         LowestRate
100123     90.00                   75.00

Any help would be appreciated!



100124     85.00                   80.00
100125     90.00                   90.00
Question by:Lapchien
    1 Comment
    LVL 9

    Accepted Solution

    Try this.
    select jobId,Max(Rate)  HighestRate,min(Rate) LowestRate from tmpTable group by jobid

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now