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
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

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

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
Messages: 25544
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

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: 65090
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.

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

Current Time: Thu Jul 27 16:08:12 CDT 2017

Total time taken to generate the page: 0.08790 seconds