Home > Not Working > Sql Distinct Not Working With Join

Sql Distinct Not Working With Join

Contents

How many seconds are a meter in the 4th dimension? Please click the link in the confirmation email to activate your subscription. not quite you have OrderID in the GROUP BY, so MIN(OrderID) always returns each OrderID Comments on this post Vomster  agrees : haha ;) rudy.ca | @rudydotca Buy my SitePoint Cheers! this contact form

if there are multiple records to be taken, what is the result we want to have? The TOP 10 requires a lot less logical reads getting data for the entire table. This documentation is archived and is not being maintained. For MS SQL Server, you need to use CONVERT(VARCHAR(10), work_start_dt, 120) instead of TRUNC(work_start_dt), obviously. 6. find more info

Sql Distinct Not Working With Join

All rights reserved. Suggested Articles Title Views Activity Data caching, performance and security 2,388 15h Introduction to Oracle APEX SQL Workshop- The object browser 621 15h Introduction to SQL Command Tool in Oracle APEX more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed One of the problems you may be faced with is that you want to get a distinct list of values from a table to show the differences in your table, but

Actually the number of rows i get are huge.Is there a way to check if i am getting unique values? –sriram Mar 5 '12 at 18:55 1 Don't trust the Username Forum Password I've forgotten my password Remember me This is not recommended for shared computers Privacy Policy Jeff's SQL Server Blog Random Thoughts & Cartesian Products with Microsoft SQL Server Reply roopeshreddy Star 14065 Points 3271 Posts Re: Distinct keyword not working in sql server Jul 06, 2012 05:58 AM|roopeshreddy|LINK Hi, I suspect the syntax -http://blog.sqlauthority.com/2007/12/20/sql-server-distinct-keyword-usage-and-common-discussion/ Hope it helps u... Distinct Not Working C# You’ll be auto redirected in 1 second.

The example returns all employees with lastname starting with 'B'. Then your output will be "one row per distinct combination" of the 3 fields. DISTINCT is not a function ... ... http://stackoverflow.com/questions/23851157/sql-distinct-not-working You might find some subquery in subquery syntax, but honestly: don't try, just use the much easier and still efficient method shown now: -- oracle select sq.* from (

Result A So, let's take this query, which is using the correlated subquery technique, which works also for all databases: select t.* from tbl_Employee_WorkRecords t where t.work_start_dt = Sql Group By Not Working In short, Result C is a variation of Result B, if you look closely at it. 7. more hot questions question feed lang-sql about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Why (and when) does pattern matching with f[__] perform MUCH more quickly than _f?

  1. And how many roqws it will execute and how much each query will take.
  2. Usually, you don't use DISTINCT or GROUP BY for these scenarios, either.
  3. LEARN MORE Join & Write a Comment Already a member?
  4. Code: SELECT UsersTable.UserID, UsersTable.FirstName, UsersTable.LastName , MIN(OrdersTable.OrderID) from UsersTable INNER JOIN OrdersTable on OrdersTable.UserID = UsersTable.UserID GROUP BY OrdersTable.OrderID, UsersTable.UserID, UsersTable.FirstName, UsersTable.LastName Faq Reply With Quote April 19th, 2011,10:10 PM #10
  5. Learn from the classics in the field and the better advanced textbooks; don't be satisfied with the easily digested "how to" guides and online documentation - it's shallow.-- Bjarne StroustrupHe that
  6. How do I handle this?

Select Distinct Not Working With Join

The good method to solve the problem is to step back, and look at both the data and the requested output, which, once clarified, can be translated into SQL Query "easily". http://weblogs.sqlteam.com/jeffs/archive/2007/10/12/sql-distinct-group-by.aspx C++ implementation of Hackerrank's "Maximum Element in a Stack" How can I ensure my Playstation 2 will last a long time? Sql Distinct Not Working With Join see also: Some SELECTs will never return 0 rows -- regardless of the criteria A handy but little-known SQL function: NULLIF() Is it a String Literal or an Alias? Select Distinct Not Working Access Understanding which string breaks when one pulls on a hanging block from below Would the members of an online imageboard (or any community) be able to build a post-apocalytic society upon

Ugh, yes--seen this several times.Even worse, something like:SELECT DISTINCT(EmployeeId), MAX(Salary)FROM SalaryHistGROUP BY EmployeeId 10/12/2007 11:18 AM | Adam Machanic #re: By The Way ... http://elliottwaveresearch.com/not-working/bmw-e61-key-fob-not-working.html Faq Reply With Quote April 19th, 2011,11:18 AM #4 Vomster View Profile View Forum Posts  Contributing User Devshed Novice (500 - 999 posts)        Not the answer you're looking for? We could use the RANK or DENSE_RANK function also, modifying the ORDER BY argument a little bit: -- oracle select sq.* from ( SELECT t.* , RANK Distinct Not Working Oracle

Several functions may not work. Faq Reply With Quote April 19th, 2011,08:01 PM #7 Vomster View Profile View Forum Posts  Contributing User Devshed Novice (500 - 999 posts)        for everybody? navigate here Yes No Tell us more Flash Newsletter | Contact Us | Privacy Statement | Terms of Use | Trademarks | © 2016 Microsoft © 2016 Microsoft

Passing an Array or Table Parameter to a Stored Procedure SELECT * FROM TABLE -- except for these columns In SQL, it's a Case Expression, *not* a Case Statement Returning Random Distinct On One Column select … where id in (…)213SQL/mysql - Select distinct/UNIQUE but return all columns?0Select Distinct Certain Columns From Result2Select distinct and non-distinct column values0Join two queries from the same table - SELECT Work to make "programming" more of a professional activity and less of a low-level "hacking" activity (programming is also a craft, but not just a craft).

asked 10 months ago viewed 168 times active 10 months ago Upcoming Events 2016 Community Moderator Election ends in 9 days Related 471How can I SELECT rows with MAX(Column value), DISTINCT

Query: Code: SELECT UsersTable.UserID, UsersTable.FirstName, UsersTable.LastName , MIN(OrdersTable.OrderID) from UsersTable INNER JOIN OrdersTable on OrdersTable.UserID = UsersTable.UserID GROUP BY MIN(OrdersTable.OrderID), UsersTable.UserID, UsersTable.FirstName, UsersTable.LastName Faq Reply With Quote Share This Thread  For example, if you select all the product IDs in ProductInventory without DISTINCT, 1069 rows are returned. it's been fixed! 0 LVL 12 Overall: Level 12 Databases 1 Message Expert Comment by:jkaios2014-09-10 Comment Utility Permalink(# c125421) Another 'YES' to a great article and unselfish contribution to the Mysql Select Distinct Thank you, a3! 0 Featured Post Looking for New Ways to Advertise?

All-Star 27268 Points 6185 Posts Re: Distinct keyword not working in sql server Jul 06, 2012 06:07 AM|kedarrkulkarni|LINK select distinct(subcatid) dosent mean you are taking distinct of subCatId column... Request: Presume we want to see the last work day, per employee. What is the meaning of "cow in the middle"? http://elliottwaveresearch.com/not-working/css-top-not-working.html View all my tips Related Resources More Database Developer Tips...

How to find limit of function. Can Newton's laws of motion be proved (mathematically or analytically) or they are just axioms? To show you another example here is just a quick way of selecting the case sensitive or case insensitive option. I have a table of order line items.

but often! 0 LVL 2 Overall: Level 2 Message Expert Comment by:wellso2010-06-03 Comment Utility Permalink(# c15293) angellll you are the database king, very informative article, feel alot more confident in Pick Randomly Between -1 or 1 Wrong way on a bike lane? I dont get it full, but i'm gonna look for "Varchar(max). Distinct not working Started by Hogwilde1, Jan 27 2015 12:33 PM SQL distinct query Please log in to reply 1 reply to this topic #1 Hogwilde1 Hogwilde1 Newbie Members 1 posts

Rick -- DISTINCT in that case is still not a function; it is a tag or a flag on the aggregate function indicating to only count or sum distinct values. 10/12/2007 Related 187SQL to find the number of distinct values in a column471How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?9why does hibernate hql distinct cause an What is the more appropriate adjectival form of Trump? Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Faq Reply With Quote April 19th, 2011,01:26 PM #5 r937 View Profile View Forum Posts Visit Homepage  SQL Consultant Devshed Supreme Being (6500+ posts)       Please help. *This is MS SQL SERVER ENTERPRISE 2008. *I get duplicated students... Updated my answer. –Mosty Mostacho Mar 6 '12 at 1:06 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up