Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8842139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:53:24+00:00 2026-06-14T10:53:24+00:00

I would like to formulate a query that returns the vin , customer_id and

  • 0

I would like to formulate a query that returns the vin, customer_id and model_id where the same customer_id has multiple records that have a model_id of “toyota” from the CAR table. The vin in the primary key and unique. Any ideas? I’m using Oracle 10g.

CAR Table:

vin varchar (primary key)
customer_id varchar
model_id varchar

Data:

vin        customer_id   model_id 
------------------------------------  
222313XYZ,   cust1234,   toyota
123232SSS,   cust1234,   toyota
111111ERE,   cust1111,   bmw
999999LKO,   cust1224,   bmw
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:53:26+00:00Added an answer on June 14, 2026 at 10:53 am

    SQL Fiddle

    Oracle 11g R2 Schema Setup:

    CREATE TABLE car
        (vin varchar2(9), customer_id varchar2(8), model_id varchar2(6))
    ;
    
    INSERT ALL 
        INTO car (vin, customer_id, model_id)
             VALUES ('222313XYZ', 'cust1234', 'toyota')
        INTO car (vin, customer_id, model_id)
             VALUES ('123232SSS', 'cust1234', 'toyota')
        INTO car (vin, customer_id, model_id)
             VALUES ('111111ERE', 'cust1111', 'bmw')
        INTO car (vin, customer_id, model_id)
             VALUES ('999999LKO', 'cust1234', 'bmw')
    SELECT * FROM dual
    ;
    

    Query 1: in case you want to see all models whose owners also own more than one toyota

    select vin, customer_id, model_id from (
     select vin, customer_id, model_id, 
     count( decode(model_id, 'toyota', 1) ) over (partition by customer_id) cnt
      from car
    )
    where cnt > 1
    

    Results:

    |       VIN | CUSTOMER_ID | MODEL_ID |
    --------------------------------------
    | 999999LKO |    cust1234 |      bmw |
    | 222313XYZ |    cust1234 |   toyota |
    | 123232SSS |    cust1234 |   toyota |
    

    Query 2: in case you want to see only toyotas whose owners own more than one of them:

    select vin, customer_id, model_id from (
     select vin, customer_id, model_id, 
     count(*) over (partition by customer_id) cnt
      from car
     where model_id = 'toyota'
    )
    where cnt > 1
    

    Results:

    |       VIN | CUSTOMER_ID | MODEL_ID |
    --------------------------------------
    | 123232SSS |    cust1234 |   toyota |
    | 222313XYZ |    cust1234 |   toyota |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like a for loop in jquery so that: For every hover_link: show hidden
Would like to make anapplication in Java that will not automatically parse parameters used
I have users stored in a database that has latitude and longitude set on
I have a mysql table that looks something like this: id | col_1 |
I have a table that look like this: property propertyid value active 1 1
I have a query that attempts to find things within a certain geolocation, but
I have an object w/ an NSString for a property. I would like to
So I have a SQL query that gives me a list of ints. Listed
So i have a query that is suppose to get me data from two
Do I have to formulate all of my strings in java like Some static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.