Posts

Showing posts with the label SQL

Rank Operation Using SQL

Rank - Make ranking structure using SQL tool                If we have collection of data and we want to make it an well structure by reduce duplication and make view based on ranking; we have a simple and easy option to do this operation.It is called Rank. For example we have data such like,   Name        Sales John           10 Jennifer      15 Stella          20 Sophia       40 Greg          50 Jeff            20 The general idea to display rank in SQL is to do a  self-join , then list out the results in order, and finally do a count on the number of records that's listed ahead of (and including) the record of interest. So, we coming back to discussion. we have to make this data in ranking based order.so lets start with the query, SEL...
Conditional statement in SQL           W e have an if condition in programming sector to handle the conditional operation. Like that in SQL conditional operation done by using CASE statement. A sample example of CASE statement in sql is given below,        syntax,       SELECT CASE ("column_name")      WHEN "value1" THEN "result1"     WHEN "value2" THEN "result2"         ...        [ELSE "resultN"]      END     FROM "table_name";     eg:           SELECT Store_Name, CASE Store_Name           WHEN 'Los Angeles' THEN Sales * 2           WHEN 'San Diego' THEN Sales * 1.5           ELSE Sales           END           "New Sales",         ...