A0

Labels

Showing posts with label oracle sql. Show all posts
Showing posts with label oracle sql. Show all posts

How to develop logic?

 Logic Development

Have you heard programmer is nothing without logic? If yes then you should definitely read this article to which can help you in development of logics.

Before some practices we should understand what is logic? can you answer this question? you should answer if you don't know then don't worry I will answer you. "The ability to solve any problem". If you know better answer then you can comment below this will also increase my understand related to logics. So what ever, now I should come to point that how to develop logic?

logic development dowatse


How to develop

 Here please try to answer these questions.

1) How can you add 2 odd numbers to get even answer?

Answer:

Yes I know answer is too simple and definitely you had answered this question but I should also contribute my answer which is add 1+1 =2(odd +odd=even) . This is called logics and by solving these kinds of problems you can enhance you logics. Now try to solve question two.

2) Now try to solve by adding 3 odd numbers to get even answer?

Answer:
This is called logic now may be you are confuse here and may be your answer will be this is not possible but here I did not limit you, you can use any of the method to solve this question.

Hint: you can also use decimal numbers.

May be now you can solve this question. If not then don't worry I will tell you so the answer is 
5 + 3.9 + 1.1 =10 (odd + odd + odd= even).


Now, you had learnt the solution of another problem and do you know the meaning of it. Meaning of it, is you had develop your logic by solve these complex problems. Now you have to add this logic into programming (these are the sets of instructions which a machine follows to perform any task). If I will tell you to define that question 1 into the set of instructions. you can use any language to define instructions and at the same time I will also solve this question and answer is below

1) initialize three variables one for first number, second for second number and third for answer 
2) Now assign the first two variables with number
3) Now, add the first two variables and store the answer into third variable
4) Now you can display the answer.

I will solve this question in this way you can also use your own way to define instructions also you don't need to use the line of initialize or assigning because you don't know the meaning of it because now you are beginners. We will learn this in the next blogs.


Tips to improve Logic

1) Solve critical problems
2) try to solve same problem with different ways
3) Play logical games such as Castle Crash or Candy crash etc
4) Critical Programming practices is one of the best way to improve logics.


There are tons of others ways which can improve your logics but these are the only one's which are on my mind which I had shared.

Stay connected for more these kinds of articles.



 



Operators and Precedence in Oracle SQL

 

Operators

We can also use the operators while writing the queries eg +, -, *, / and ^. By using these operators we can display output in more accurate way for example if the salary for the employee is 500 per month and we want to display this salary for an year then by using the operators we can easily display the output. We can solve this query by multiplying the monthly salary with 12 months. After calculating output will be 500*12 =6000. 

Do you solve this?

2*3/5+1 

Maybe some people who did not know about the precedence of the operators they cannot solve this question . Therefore, I can help those people who do not know about the precedence of the operators.


Precedence of Operator:

                             *,/ has the same precedence and +,- has the same precedence which works from left to right. If we talk about the complete precedence then this will be like braces then power then divide and Multiply (works from left to right), plus and minus (works from left to right) .

So by following this precedence we can solve ever equation in Oracle SQL. Now we should solve the above equation which is 2*3/5+1.

Here firstly we will solve multiply part and solve it equation will be like 6/5+1 now we will solve division after this equation will 1.2+1 and after adding answer will be 2.2. I can also provide the screen shot for this question on SQL Plus. So the answer is

2*3/5+1
Here may be you are thinking what is dual don't worry dual is a dummy table which we uses in Oracle SQL for the answer. We can use this table when we are not dealing with the physical table in database. SO this was for today and stay connected with dowaste for more concepts related to Oracle SQL.


Select Statement and Distinct Keyword

 


Select Statement:

So this is the first blog related to oracle SQL. Today lecture will about the select statement which is one of the important topic in Oracle SQL. It is used to retrieve(show) the data. For example there is employee table in the database and by using select statement we can show the whole data which is present in the table. So here is the query related to select statement.

e.g

select * from emp;

Here * is use as whole. If I will translate this query in simple words  then the meaning of this query will be select or show the whole data from employee table. If I will use this query than output will be this kind.

select * from emp;


In this way we can use the select statement to show the output from database.

Distinct Statement:

Distinct is the keyword which will become statement when we use select with it. We can use distinct keyword only with select statement. Now here question is arising why we use distinct keyword?

Answer for this question is, if there is any duplicate name or value etc in the table then we use this keyword. By using this keyword we can remove the duplicate names or any value from the table. Here I will also provide you the example to use this.

If I will use

select distinct ename from emp;

If I will translate this query in simple words then this query is saying that select the ename values without duplication and the output for this query will be this kind.

select distinct ename from emp;

In this way we can use select statement and distinct keywords. This is enough for today If you need more about oracle sql then visit the SQL section from manu.