Hi saikumar,
You can create a Stored Procedure or write inline query and fill it in datatable and assign that datatable to gridview.
Refer below article for binding the gridview with datatable
and if you are using SqlDataSource then refer below article