Optimization of for loop in oracle [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I was asked on my apprenticeship following question:
Why query like:
FOR i in ( SELECT * FROM TABELKA) LOOP
is not efficient? How to change it to make it more efficient?
There is no further information added.

Collect, all data at once, into a collection. Boom! One query and you have it all without looping.
SELECT *
BULK COLLECT INTO a_collection_type_variable
FROM a_table;

Related

How to compare data in SQL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have an application which is taking data from questionnaires users are completing on a website and inputting this into a SQL Lite database.
I'm using Django and would like to display data of users who match closest by selecting similar answers.
How could this be done?
You can add multiple join conditions like this
SELECT *
FROM <table>
INNER JOIN <same table different name>
ON (condition1 OR condition2 OR condition3)

Oracle Query not Working [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
oracle query is not working. Please specify what is wrong in this query?
(select hacker_id,challenge_id, max(score) as soc
from submissions
group by hacker_id,challenge_id
having max(score)>0) t2;
Please read #OldProgrammer comments. Anyway, I think this should work for you
select hacker_id,challenge_id, max(score) as soc
from submissions
group by hacker_id,challenge_id
having max(score)>0;

SQL Image field divided by 2 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Could anyone help me on the below please?
I have a field called F1.Images and I need to divide by 2 ONLY when my other field W1.Plex is Duplex else I need to retain the F1.Images count.
Thanks Satya
Sorted Brad.
Used Case/When logic. Here's the Answer:
Case
WHEN W1.Plex = 'Duplex' then (F1.images / 2)
Else F1.images
End AS Pages

Simple select query running slow [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have about 1000 entries in table. It's simple table with 10 columns. Query:
SELECT * FROM my_table
server runs the query, but is processing it for a long time.
P.S. I know this is not enough info, so please comment and I will add what is needed.
Got it. Not related to SQL. Server got overflown by data. Someone was spamming it.
You can try to use TOP. For example try to select 100 rows and look if server still stucks:
SELECT TOP 100 * FROM my_table

Need to replace a part of a value in Sql Server 2005 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My table name is SOFTSKILL. One of Columns is MakeID. The values in the column are,
000277755
000278143
000277738
000277051
i need to change 000 into 100, like
100277755
100278143
100277738
100277051
Anybody please help me how to do this..
UPDATE SOFTSKILL
SET MakeId = STUFF(MakeId,1,1,'1')
WHERE MakeId LIKE '000%'