SQLTeam.com | Weblogs | Forums

Can someone help me the code for my class?

Hello

I am pretty new to learn SQL for database management.
Can someone help me with this code for this query?

Create a query to select all rows from the CONDITION_OCCURRENCE table with ICD codes of ‘25002’ and ‘2469’.

thanks in advance

K

https://www.w3schools.com/sql/sql_and_or.asp

1 Like

Hi Ifor
Can you write the specific query, i know this link and I have been learning from it, but it is not helping directly.
thanks
K

hi

looks like you are in need of a quick fix

i have been in your same situation many many times
takes time to learn ( things are not straight forward ) ... and the assignment needs to be done ..
:slight_smile:

Here it is .. :slight_smile:

-- if ICD codes are integers
select * from
CONDITION_OCCURRENCE
where ICD_Code in (25002,2469)

-- if ICD codes are characters
select * from
CONDITION_OCCURRENCE
where ICD_Code in ('25002','2469')

hope this helps !!!

1 Like

Thanks a lot!!

Hi Haris

Thanks for your codes, but I put into my db SQL, it shows syntax error and red syntax area this:

look like it does not work? I am sure ?

Result: no such column: ICD_Code
At line 1:
select * from
CONDITION_OCCURRENCE
where ICD_Code in (25002,2469)

You haven’t provided adequate information to answer your question, however my guess is the column name IDC_code is not correct. Is the column IDC? If so:

SELECT *
FROM CONDITION_OCCURRENCE
WHERE IDC IN (25002’, ‘2469’j;

Hello Torre

thanks so much for trying to help me. What information do you need to write this query?

I will provide if you tell me?

anyway, I have problem with this because ICDcode is NOT a column or a table and it does not exist in any of the context of the database of my assignment, but somehow my teacher brought it up in his assignment.
that is why i have trouble and I do not know what to do to elicit this information of ICDcodes somewhere hidden.

what is your thought?

thanks

Katherine

Hi Torres again,

I think i figure out that I need to tell you about the files, there are two files called OMOP and one called TERMS. and I attached them together in the DB SQLite platform already so indeed there are two sets of tables one of the OMOP and one of the TERMS, but both of them do not contain ICDcode as column or table anywhere in the two sets. But, I do not know if the ICDcodes are the text content within these tables or how to elicit them, need to write a complex query?? i do not know.

thanks
Katherine

Please provide all of the columns or what some call fields of the table named CONDITION_OCCURRENCE.
Also show us what data type each column is: date, int, varchar etc.

Try right click on the tables and select Script Table As and then select Create To and choose new query editor.

Copy and paste the output here so others can see the table structure. This way they can probably help better.

HTH

1 Like

Hi Yosiasz and New_Creative

here are all the columns of the condition_occurence table:

from top down:

  • condition_occurence_id
  • person_id
  • condition_concept_id
  • condition_start_date
  • condition_start_datetime
  • condition_end_date
  • condition_end_datetime
  • condition_type_concept_id
  • stop_reason
  • provider_id
  • visit_occurence_id
  • condition_source_value
  • condition_source_concept_id
  • condtion_status_source-value
  • condition_status_conceppt_id

so above are all the colummn i provided, i hope this can shed some light?

thanks for your interest in helping me out with my assignment!

Katherine

Please try this ...

Select * from
CONDITION_OCCURRENCE
where ICD_Code = 25002 OR

ICD_Code = 2469

And now please provide the data type of each column. Whether string, date, boolean, money, decimal etc

In which of these columns you provided do the values 25002’ and ‘246 exist?

in the list of the column names provided I do not see ICD_Code

By the way we will not help you out with your homework but we will guide to find the answer

Hi Yosias

no none of the column shows anything about ICDcodes so even i try to type all the data types you want, it does not help, need a different way?

Right, i want to learn myself, it is not only the homework, my teacher would not penalize this, but i want to learn how to do it at the first place

Hi Haris
that query doesnt work/
it show syntax error with the red area again.

I put in a different one as below and it turns back zero, i know this is not correct as what it requires

Create a query to select all rows from the CONDITION_OCCURRENCE table with ICD codes of ‘25002’ and ‘2469’. You can choose other codes if you prefer—just document what you did and why

25002

SELECT *

FROM condition_occurrence

WHERE condition_concept_id = 25002

Result: 0 rows returned in 516ms

At line 1:

SELECT *

FROM condition_occurrence

WHERE condition_concept_id = 25002

2469

SELECT *

FROM condition_occurrence

WHERE condition_concept_id = 2469

Result: 0 rows returned in 2ms

At line 1:

SELECT *

FROM condition_occurrence

WHERE condition_concept_id = 2469

I do not know what else to do.........

In your original post you said

Create a query to select all rows from the CONDITION_OCCURRENCE table with ICD codes

Obviously it is in the CONDITION_OCCURRENCE table.
Which column in the table is supposed to contain those icd codes? What are icd codes?

the data does not indicate which table or column contains this, but there are two sets of data is the OMOP and the CONCEPT TERMs, and I assume it is the concept terms, have no idea.