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 9174339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:44:14+00:00 2026-06-17T16:44:14+00:00

I have following scenario, for which i need to write sql query. I have

  • 0

I have following scenario, for which i need to write sql query.

I have ICCID table and ICCID property table which holds following information.

enter image description here

I want to find out all active iccids and iccid’s which are in removed state in month of december 2012.for ICCIDs which are in removed state, date.to.change key in the ICCID property table itself which record the removed date of ICCID.

this is my attempt, but that did not worked
     select e.ID_ICCID from ICCID_PROPERTY e where 
     e.c_key ='STATE' and e.c_value='Active' or(
     e.c_key ='STATE' and 
     e.c_value='Removed' and
     e.c_key='date.to.change' and  
     to_date(e.c_value,'yyyymmdd')  >=to_date('2012-DEC-01 00:00:00', 'YYYY-MON-DD HH24:MI:SS') and 
     to_date(e.c_value,'yyyymmdd')  <= to_date('2012-DEC-31 23:59:59', 'YYYY-MON-DD HH24:MI:SS')
     ))

Thanks in advance for any 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-06-17T16:44:16+00:00Added an answer on June 17, 2026 at 4:44 pm

    This is one of the issues with a key-value pair design such as this…

    You can’t just check a single property row to see if it matches the search criteria, since the criteria in this case will span multiple properties… you have to check if a single parent row has all the children properties that match:

    SELECT
        i.ICCID
    FROM
        ICCID i
    WHERE
        EXISTS (
            SELECT 1
            FROM ICCID_PROPERTY ip
            WHERE 
                ip.ID_ICCID = i.ID_ICCID
                AND ip.c_key = 'STATE'
                AND ip.c_value = 'Active'
        ) OR (
            EXISTS (
                SELECT 1
                FROM ICCID_PROPERTY ip
                WHERE 
                    ip.ID_ICCID = i.ID_ICCID
                    AND ip.c_key = 'STATE'
                    AND ip.c_value = 'Removed'
            ) AND
            EXISTS (
                SELECT 1
                FROM ICCID_PROPERTY ip
                WHERE 
                    ip.ID_ICCID = i.ID_ICCID
                    AND ip.c_key = 'date.to.change'
                    AND to_date(ip.c_value,'yyyymmdd') >= 
                        to_date('2012-DEC-01 00:00:00', 'YYYY-MON-DD HH24:MI:SS') 
                    AND to_date(ip.c_value,'yyyymmdd') <= 
                        to_date('2012-DEC-31 23:59:59', 'YYYY-MON-DD HH24:MI:SS')
            )
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario. I have a search page which is split into
I am trying to understand isolation/locks in SQL Server. I have following scenario in
I have the following scenario where I want to pass in string and a
I have the following SQL problem. Scenario: I have two tables: Change and ChangeTicket.
i need to implement following scenario, here i have two horizontalScrollViews the upper scrollView
I need to automate web browsers in the following scenario : I have a
I need to write a regular expression in Java which covers the following scenarios
I have the following scenario where I have a page say parentPage.html, which contains
I am a newbie with Matlab and I have the following scenario( which is
I have the following scenario. I'm working with a server which has a lib

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.