Home » SQL & PL/SQL » SQL & PL/SQL » determine number of times a value appears - sql (oracle 11g)
determine number of times a value appears - sql [message #570526] Sun, 11 November 2012 19:37 Go to next message
deltamfox
Messages: 3
Registered: November 2012
Junior Member
Hi, i am trying to determine the number of times a value appears and display the count. However the value can only be counted once per 'trip' even though it may appear several times per trip.

for e.g

Quote:
trip table
-------
trip_id start_date end_date duration
445 01-jan-12 03-jan-12 3


Quote:
pickup table
--------
pickup_id trip_id company
1 445 randomname
2 445 randomname
3 445 google.inc
4 878 randomname


with the above data the expected value would be two because the trip id appears twice so it was just the one trip - given a count of one.

I am not sure how create a query to check this. Could someone please help me by point me in the right direction at least?

Thank you for any assistance.

[Updated on: Sun, 11 November 2012 19:39]

Report message to a moderator

Re: determine number of times a value appears - sql [message #570527 is a reply to message #570526] Sun, 11 November 2012 19:42 Go to previous messageGo to next message
BlackSwan
Messages: 23146
Registered: January 2009
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: determine number of times a value appears - sql [message #570535 is a reply to message #570526] Sun, 11 November 2012 23:43 Go to previous message
Michel Cadot
Messages: 59991
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
We had no feedback on your previous topic, I'm waiting on it and so can't help you in this one.

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, please, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Regards
Michel
Previous Topic: Create object then use as data type of new table
Next Topic: pl/sql with amount due
Goto Forum:
  


Current Time: Fri Dec 19 07:02:11 CST 2014

Total time taken to generate the page: 0.09616 seconds