Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/praveen-334/sql-queries
https://github.com/praveen-334/sql-queries
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/praveen-334/sql-queries
- Owner: praveen-334
- Created: 2024-08-10T06:39:12.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-10T06:50:29.000Z (5 months ago)
- Last Synced: 2024-08-10T08:13:21.283Z (5 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SQL-Queries
## Scenario:
### Perform SQL queries to create tables and extract meaningful information from a Student and Course database.## CODE:
```sql
CREATE TABLE Student (
RollNo INT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
Marks DECIMAL(5, 2) NOT NULL,
AadharNumber CHAR(12) UNIQUE NOT NULL,
Address VARCHAR(255)
);
CREATE TABLE Course (
RollNo INT,
Course VARCHAR(100) NOT NULL,
Course_Duration VARCHAR(50),
FOREIGN KEY (RollNo) REFERENCES Student(RollNo)
);
INSERT INTO Student (RollNo, Name, Marks, AadharNumber, Address)
VALUES
(1, 'John Doe', 85.5, '123456789012', '123 Elm Street'),
(2, 'Rane Smith', 25.0, '987654321098', '456 Oak Avenue'),
(3, 'Alice Johnson', 78.0, '111223344556', '789 Pine Road');
INSERT INTO Course (RollNo, Course, Course_Duration)
VALUES
(1, 'BCA', '6 months'),
(1, 'MBA', '6 months'),
(2, 'BBA', '6 months'),
(3, 'BCA', '6 months');SELECT AVG(Marks) AS AverageMarks
FROM Student;
SELECT Name
FROM Student
ORDER BY Name ASC;
SELECT RollNo, NameFROM Student
WHERE Marks < 30;
SELECT RollNo
FROM Student
WHERE Name LIKE 'R%';
SELECT DISTINCT RollNo
FROM Course
WHERE Course = 'BCA';Output:
AverageMarks
----------------------------------------
62.833333
Name
----------------------------------------------------------------------------------------------------
Alice Johnson
John Doe
Rane Smith
RollNo Name
----------- ----------------------------------------------------------------------------------------------------
2 Rane Smith
RollNo
-----------
2
RollNo
-----------
1
3