[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Select Query Issue

Posted on 2013-01-23
3
Medium Priority
?
233 Views
Last Modified: 2013-01-23
Hi

I have a SQL query that brings up two lines for the same invoice
How would I do a further Select on this that only shows the first date

Supplier      Ref      Total      Due      Date
boston breweries      28924      4 990.34      4 990.34      2012/12/30
boston breweries      28924      4 990.34      4 990.34      2013/01/17
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 38809353
please read up this article:
http://www.experts-exchange.com/Database/Miscellaneous/A_3203-DISTINCT-vs-GROUP-BY-and-why-does-it-not-work-for-my-query.html

it will explain that you just have to clarify the rule on which row you want to show up (in your case, which "date" to choose), and formulate the sql accordingly
0
 
LVL 18

Expert Comment

by:deighton
ID: 38809472
SELECT * FROM (SELECT DQ.*, row_number() OVER(PARTITION BY DQ.supplier,    DQ.Ref,   DQ.Total,   DQ.Due ORDER BY DQ.date)  AS ROWN
FROM (<your exisitng query here>) DQ) DQ2
WHERE DQ2.ROWN=1
0
 

Author Closing Comment

by:Murray Brown
ID: 38810084
thanks very much
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

656 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