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

  • SEARCH
  • Home
  • 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 3456890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:47:34+00:00 2026-05-18T09:47:34+00:00

My query select kc.prod_id, kc.prod_actv_ts from kit_cmpnt kc ,kit_cmpnt_stock kcs, prod p where kc.cmpnt_cd=’016′

  • 0

My query

select kc.prod_id, kc.prod_actv_ts 
from   kit_cmpnt kc ,kit_cmpnt_stock kcs, prod p
where kc.cmpnt_cd='016' 
and   kcs.kit_cmpnt_nbr= kc.kit_cmpnt_nbr 
and   kcs.stock_id=1 
and   kcs.prod_id=kc.prod_id 
and   kcs.prod_actv_ts=kc.prod_actv_ts 
and   p.prod_id= kc.prod_id 
and   p.prod_actv_ts= kc.prod_actv_ts 
and   p.prod_inactv_ts is null;

I want to get a distinct combination of kc.prod_id, kc.prod_actv_ts

like distinct(kc.prod_id, kc.prod_actv_ts)

But what i am getting is a combination of repeated prod_id and prod_actv_ts

please help

  • 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-05-18T09:47:35+00:00Added an answer on May 18, 2026 at 9:47 am

    I’d restructure the query as follows :

    select kc.prod_id, kc.prod_actv_ts 
    from   kit_cmpnt kc 
    where  kc.cmpnt_cd='016' 
    and exists
           (select 1 from kit_cmpnt_stock kcs 
            where kcs.stock_id=1 
            and    kcs.kit_cmpnt_nbr= kc.kit_cmpnt_nbr 
            and   kcs.prod_id=kc.prod_id 
            and   kcs.prod_actv_ts=kc.prod_actv_ts)
     and exists
           (select 1 from prod p
            where   p.prod_id= kc.prod_id 
            and   p.prod_actv_ts= kc.prod_actv_ts 
            and   p.prod_inactv_ts is null);
    

    General principle is that you shouldn’t have something in the FROM clause unless you are taking something from it. If you aren’t taking anything from it, it is a filter and should be in the WHERE clause as a subquery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below query: SELECT p.id as prod_id, * FROM products AS p
Query: SELECT u.user_id,r.totalVotes votes,r.totalPoints rating,@row:=@row+1 rank FROM mismatch_user u LEFT JOIN ratingItems r ON
Query: SELECT DISTINCT ([Equipment List].ID) AS Expr1, [Job Assignments].Job FROM [Equipment List] LEFT JOIN
My Query SELECT DATE, SEC_TO_TIME( SUM( TIME_TO_SEC( `total_hours` ) ) ) AS total FROM
this query SELECT * FROM tblContracts LEFT JOIN tblPartys ON tblContracts.id = tblPartys.Contract_id INNER
SQL query: SELECT ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date FROM ArticleCategories INNER JOIN Articles
Why query: SELECT id, MAX(probe_time) AS Expr1 FROM app_states GROUP BY logon_id and SELECT
this is the mysql query SELECT * FROM users AS up JOIN users AS
i have this sql query select * from table where name like ? but
I have the following SQL query SELECT tbl_product.prod_id, ISNULL (prod_code, '') AS prod_code, ISNULL

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.