MS SQL

MS SQL

Trending Questions and Lessons

Follow 5,550 Followers

Feed

Ask a Question

All

Lessons

Discussion

Overview

Questions 406

Lessons 61

Total Shares  

Asked on 31 May IT Courses/MS SQL Tuition/BTech Tuition/Big Data Analytics Tuition/BTech Tuition/Algorithms And Data Structures +1 IT Courses/RDBMS less

I want to teach SQL DBMS Algorithm to CS and IT students for free on Saturday and Sunday. I am a specialist... read more
I want to teach SQL DBMS Algorithm to CS and IT students for free on Saturday and Sunday. I am a specialist and trying something new. So, in need to sharpen some of my basic skills. Is anyone there. Classes at my home and student must be too curious to do something new. read less

Answer

Answered on 21 Apr IT Courses/MS SQL

Manoj Kumar Vishwakarma

MS SQL DBA Trainer

Should be have good knowledge and pracically experience in DBA then u will be success in market so should be take training in HA by wroking Guys.
Answers 3 Comments
Dislike Bookmark Share

Answered on 21 Apr IT Courses/MS SQL/MS SQL Administration IT Courses/MS SQL/MS SQL Development IT Courses/MS SQL/MS SQL Integration

Abdul

Trainer

Hi. give me details . will give better solution to you.
Answers 5 Comments
Dislike Bookmark Share

Lesson Posted on 27 Feb Tuition IT Courses/MS SQL

MS-SQL Database

Prashant Kumar

I had took classes on C and database during college have 3 year experience of teaching of polytechnic...

1. Select: 01-Select All Given a City table, whose fields are described as: +-------------+----------+ | Field | Type | +-------------+----------+ | ID | int(11) | | Name | char(35) | | CountryCode | char(3) | | District | char(20) | | Population | int(11) | +-------------+----------+ ... read more

1. Select:

01-Select All

Given a City table, whose fields are described as:

+-------------+----------+

| Field       | Type     |

+-------------+----------+

| ID          | int(11)  |

| Name        | char(35) |

| CountryCode | char(3)  |

| District    | char(20) |

| Population  | int(11)  |

+-------------+----------+

 

1. Write a query that will fetch all columns for every row in the table.

Solution:

SELECT * FROM city;

02-Select by ID

Given a City table, whose fields are described as

+-------------+----------+

| Field       | Type     |

+-------------+----------+

| ID          | int(11)  |

| Name        | char(35) |

| CountryCode | char(3)  |

| District    | char(20) |

| Population  | int(11)  |

+-------------+----------+

You have to print all the details of the city with ID is 1661.

Solution:

SELECT * FROM city WHERE id = '1661';

03-Japanese Cities Detail

Given a City table, whose fields are described as

+-------------+----------+

| Field       | Type     |

+-------------+----------+

| ID          | int(11)  |

| Name        | char(35) |

| CountryCode | char(3)  |

| District    | char(20) |

| Population  | int(11)  |

+-------------+----------+

you have to print all the details of all the cities of Japan. The CountryCode for Japan is "JPN".

Solution:

SELECT * FROM city WHERE countrycode = 'JPN';

04-Japanese Cities Name

Given a City table, whose fields are described as

+-------------+----------+

| Field       | Type     |

+-------------+----------+

| ID          | int(11)  |

| Name        | char(35) |

| CountryCode | char(3)  |

| District    | char(20) |

| Population  | int(11)  |

+-------------+----------+

You have to print the name of all the cities of Japan. The CountryCode for Japan is "JPN".

Solution:

SELECT name FROM city WHERE countrycode = 'JPN';

05-Weather Observation Station 1

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

2. Write a query to print the list of CITY and STATE in lexicographical order of city and state, i.e., if there are two or more cities with same name arrange these by lexicographical order of state.

Solution:

SELECT city, state FROM station ORDER BY city ASC, state ASC;

06-Weather Observation Station 3

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

3. Write a query to print the list of CITY in lexicographical order for even ID only. Do not print duplicates.

Solution:

SELECT DISTINCT city FROM station WHERE MOD (id, 2) = 0 ORDER BY city ASC;

07-Weather Observation Station 4

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

Let NUM be no. of cities and NUM unique be no. of unique cities, then write a query to print the value of NUM - NUMunique

Solution:

SELECT COUNT(CITY)-COUNT(UNIQUE CITY) FROM STATION;

08-Weather Observation Station 5

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

Let |city| be the length of the city, write a query to print two lines: 1. First line is city1 and |city1| separated by space, where |city1| is the possible minimum value. 2. Second line is city2 and |city2| separated by space, where |city2| is the possible maximum value. If there are more than one possible cities print the lexicographical smallest.

Solution:

SELECT city || ' ' || LENGTH FROM

(SELECT city , LENGTH(city) AS LENGTH FROM station WHERE LENGTH(city) =

(SELECT MAX(LENGTH(city)) FROM station) ORDER BY city ) WHERE ROWNUM <= 1

UNION

SELECT city || ' ' || LENGTH FROM

(SELECT city, LENGTH(city) AS LENGTH FROM station WHERE LENGTH(city) =

(SELECT MIN(LENGTH(city)) FROM station) ORDER BY city) WHERE ROWNUM <= 1;

09-Weather Observation Station 6

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

4. Write a query to print the list of CITY that start with vowels (a, e, i, o, u) in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '^[aeiou].');

ORDER BY CITY;

10-Weather Observation Station 7

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

5. Write a query to print the list of CITY that ends with vowels (a, e, i, o, u) in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '.[aeiou]$')

ORDER BY CITY;

11-Weather Observation Station 8

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

6. Write a query to print the list of CITY that starts with vowels and ends at vowels in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '^[aeiou].[aeiou]$')

ORDER BY CITY;

12-Weather Observation Station 9

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

7. Write a query to print the list of CITY that does not start with vowels in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '^[^aeiou].')

ORDER BY CITY;

13-Weather Observation Station 10

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

8. Write a query to print the list of CITY that does not end with vowels in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '.[^aeiou]$')

ORDER BY CITY;

14-Weather Observation Station 11

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

9. Write a query to print the list of CITY that does not start with vowels or does not end with vowels in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '(^[^aeiou].|.*[^aeiou]$)')

ORDER BY CITY;

15-Weather Observation Station 12

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.

+-------------+------------+

| Field       |   Type     |

+-------------+------------+

| ID          | INTEGER    |

| CITY        | VARCHAR(21)|

| STATE       | VARCHAR(2) |

| LAT_N       | NUMERIC    |

| LONG_W      | NUMERIC    |

+-------------+------------+

 

10. Write a query to print the list of CITY that does not start with vowels and does not end with vowels in lexicographical order. Do not print duplicates.

Solution:

/* Oracle /

SELECT DISTINCT city

FROM station

WHERE REGEXP_LIKE(LOWER(city), '^[^aeiou].[^aeiou]$')

ORDER BY CITY;

2. Aggregation:

01-Average Population

Given a City table, whose fields are described as

+-------------+----------+| Field       | Type     |+-------------+----------+| ID          | int(11)  || Name        | char(35) || CountryCode | char(3)  || District    | char(20) || Population  | int(11)  |+-------------+----------+

you have to print the average population of all cities, rounded down to the nearest integer read less

Comments
Dislike Bookmark Share

Lesson Posted on 11 Jan IT Courses/MS SQL

Write A Query To Get Nth Highest Salary

Rakesh Pattanayak

I can teach each and every topics very easily and make it stronger for the students.

WITH CTE AS ( SELECT EmpID, EmpName, EmpSalary, RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC) FROM dbo.Salary ) SELECT EmpID, EmpName, EmpSalary FROM CTE WHERE RN = @NthRowUse of CTE recomended as it helps in performance of the query.
Comments
Dislike Bookmark Share

Answered on 18 Apr IT Courses/MS SQL

Subhash Chandra

Trainer

Hi Ramya, To learn the SQL there is multiple step & way's. Start learn basic queries and RDBMS Database concept. Than Installing, Configuring, and Managing Microsoft SQL Server, Sample Databases for examples Study Guide to know which topics to learn and in what order. User Community for support... read more

Hi Ramya,  To learn the SQL there is multiple step & way's. Start learn basic queries and RDBMS Database concept. Than Installing, Configuring, and Managing Microsoft SQL Server,

  1. Sample Databases for examples
  2. Study Guide to know which topics to learn and in what order.
  3. User Community for support and to help answer your questions.

Than you have to decide which filed you want to adopt as IT professional DBA or developers. On the basis of this decision you can move forward in deep for your leaning.

read less
Answers 7 Comments
Dislike Bookmark Share

Top Contributors

Connect with Expert Tutors & Institutes for MS SQL

Answered on 05/12/2017 IT Courses/MS SQL

Is inserting data with indexes slower than without indexes?

KJ Vinod Kumar

SQL And MSBI Training

Yes..Because Binary tree has to recreate if table has index while inserting the data.So it will take some time to recreate.
Answers 2 Comments
Dislike Bookmark Share

Answered on 23/12/2017 IT Courses/MS SQL

When we install a PHP MySQL application, why is it recommended that most of the subfolders not be writable?

Dr. Raginee Tiwari

Computer Expert

for security reasons it is must to protect sub folders.
Answers 1 Comments
Dislike Bookmark Share

Answered on 25/12/2017 IT Courses/MS SQL

Why do we need an SSIS when we can do everything with a SQL server?

SQL School Training Institute

SSIS is mainly used for Data Extraction, Data Formatting and Data Consolidation of Unstructured Data and also used to operate on Big Data operations. SSIS has rich User Interface tools that can be used to work with Hadoop and Azure Database / Datewarehouses which cannot be possible using T-SQL.
Answers 1 Comments
Dislike Bookmark Share

Answered on 25/12/2017 IT Courses/MS SQL

Why should we migrate from a DB2 to a SQL server?

SQL School Training Institute

SQL Server Databases has numerous advantages including : To hide data complexity. Instead of forcing your users to learn the T-SQL JOIN syntax you might wish to provide a view that runs a commonly requested SQL statement. To protect the data. If you have a table containing sensitive data in certain... read more
SQL Server Databases has numerous advantages including : To hide data complexity. Instead of forcing your users to learn the T-SQL JOIN syntax you might wish to provide a view that runs a commonly requested SQL statement. To protect the data. If you have a table containing sensitive data in certain columns, you might wish to hide those columns from certain groups of users. For instance, customer names, addresses and their social security numbers might all be stored in the same table; however, for lower level employees like shipping clerks, you can create a view that only displays customer name and address. You can grant permissions to a view without allowing users to query the underlying tables. There are a couple of ways you might want to secure your data: Create a view to allow reading of only certain columns from a table. A common example of this would be the salary column in the employee table. You might not want all personnel to be able to read manager's or each other's salary. This is referred to as partitioning a table vertically and is accomplished by specifying only the appropriate columns in the CREATE VIEW statement. Create a view to allow reading only certain rows from a table. For instance, you might have a view for department managers. This way, each manager can provide raises only to the employees of his or her department. This is referred to as horizontal partitioning and is accomplished by providing a WHERE clause in the SELECT statement that creates a view. Enforcing some simple business rules. For example, if you wish to generate a list of customers that need to receive the fall catalog, you can create a view of customers that have previously bought your shirts during the fall. Data exports with BCP. If you are using BCP to export your SQL Server data into text files, you can format the data through views since BCP's formatting ability is quite limited. Customizing data. If you wish to display some computed values or column names formatted differently than the base table columns, you can do so by creating views. read less
Answers 2 Comments
Dislike Bookmark Share

About UrbanPro

UrbanPro.com helps you to connect with the best MS SQL Training in India. Post Your Requirement today and get connected.

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more