Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL Statement Troubles

$
0
0

OK, this should pretty easy, but I can't locate any examples of what I need to save my life!! Let's say I have data that looks like the table below. I am trying to count the number of DISTINCT instances of Order_Line_No within Order_No. I can count all of the Order_No's, or I can count all of the DISTINCT values within Order_Line_No (so in other words, I'd get a 3 for the three values of 10, 20, and 30. But what I need to get is a result of 7, two for Order_No 123, 10, and 20, three for Order_No 456, 10, 20, and 30, and then two more for 789, 10, and a 20. Thanks in advance for any assistance!!

Order_NoOrder_Line_No
12310
12310
12320
45610
45620
45630
78910
78910
78920
789

20


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>