Wednesday, 26 September 2018

How to find duplicate column values with number of occurance in table

Hi user
below i am showing how to get duplicate record from the table with number of the occurrence in that column


suppose that i have two table one is employee and other one have emp_details

employee table have the master data like employee id ,name and other info and emp_details table have secondary information like address and salary so now my question in this to find out the salary that have duplicate entry


so according to my table structure i have following data in employee table

Emp id
FirstName
Last Name
Emp code
Position
location
1
Neeraj
Upadhyay
GCS-1795
Software Developer
Noida
2
Akhilesh
Upadhyay
GCS-1796
Software Developer
Delhi
3
Ashish
Bhisht
GCS-1797
Software Developer
Sawai madhopur
1002
Akash
Srivastava
GCS-1798
Software Developer
Kota
1003
Dikhsa
Rawat
GCS-1799
Software Developer
Naguar
1004
Vaishali
Gupta
GCS-1800
Software Developer
Aligarh


now the data in emp_details table
Emp_id
Address
Salary
1
behind old laxman mandir bharatpur rajasthan
50000
2
WZ-85 Todapur New delhi
50000
3
kerapati mohalla bharatpur
40000
1002
A-154/A sector 63 noida
55000
1003
india habitat center lodhi road new delhi
35000


So now we find the duplicate salary in both the table
so we execute following code


select salary,count(*) as duplicate from Employee inner join emp_details
on Employee.EmployeeID=Emp_details.emp_id
group by salary
having (COUNT(*)>1)

Saturday, 15 September 2018

What is the ref and Out keyword in C#?

consider the following program to understand the out and ref keyword of C#

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace simplevalue
{
    class Progra {
      static void Addvalue(int val)
        {
             val++
        }
      static
 void Main(string[] args)
       {
            int
 value = 10;
            Addvalue(value);
            Console.WriteLine(value);
            Console.Read();
        }
    }
}


in the above program the output of the above program is 10. because we provide the value variable to 10 after that we provide this value to Addvalue() function and in that they increment the value by 1 and become 11. but this value is never carried out to this function because we copy the value variable not reference to the variable. this is default working of the C# language .
we preferred this type of output in most of the scenario but in some cases where we want to modify the variable then we use ref and out keyword for this.

The out and ref keyword are looks quite similar in nature. Both parameters are used to return back some value to the caller of the function. But still there is a small but important difference between them. Both of the parameter type has been kept in the C# language for specific scenario.

Out keyword:
The out parameter can be used to return the values in the same variable  as a parameter of the method. Any changes made to the parameter will be reflected in the variable.
The out keyword causes arguments to be ed by reference. This is similar to the ref keyword, except that ref requires that the variable be initialized before being ed. To use an out parameter, both the method definition and the calling method must explicitly use the out keyword. 

example:
 static void Main(string[] args)
        {
            int value;
            AddValue( out value);
            Console.WriteLine(value);

            Console.Read();
        }
        static void AddValue(out int val)
        {
            val = 20; 
        }

ref keyword: 
The ref keyword on a method parameter causes a method to refer to the same variable that was ed as an input parameter for the same method. If you do any changes to the variable, they will be reflected in the variable.
The ref keyword is similer to out keyword but ref requires that the variable be initialized before being ed.
 
For example
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace outexample
{
    class Program    {
        static void value(ref int val)
        {
           val = 20;
        }
    static
 void Main(string[] args)
        {
            int value;
            value(ref value);
            Console.WriteLine(value);     
           Console.Read();
        }
    }
}

Thursday, 13 September 2018

What is the Hoisting?
         Hoisting in javascript? and what is different this as server side technology?

In javascript Hosting is that where we can use any variable or method before declaring it.
In any server side technology it is very essential to declare any variable and method before using that.
The javascript compiler moves all the declaration of the variable and function at top so there is not an error to this.


Hoisting is only possible to declare the variable not in it's initialization means according to following example let we explain this line:


alert('x = ' + x); // display x = undefined
        
var x = 1;

AdSense

The Ultimate Guide to Interceptors: Understanding Their Power and Functionality

  The Ultimate Guide to Interceptors: Understanding Their Power and Functionality An interceptor is a service that can intercept HTTP reques...

Follow