Skip to content

Fixed bugs in psql-query.md file#17

Merged
fahimahammed merged 1 commit intofahimahammed:mainfrom
DivyanshGarg380:sql-branch
Oct 3, 2025
Merged

Fixed bugs in psql-query.md file#17
fahimahammed merged 1 commit intofahimahammed:mainfrom
DivyanshGarg380:sql-branch

Conversation

@DivyanshGarg380
Copy link
Contributor

Description:
This PR adds a complete PostgreSQL SQL script that includes:

  • Department Table

    • Create department table with columns: dept_name, building, budget, num_staff, and dep_code.
    • Insert initial unique data for CSE, EEE, and ME.
    • Column alterations (ALTER TABLE) for adding/modifying columns.
  • Employee & Instructor Queries

    • Insert data from employee to employee_archive with a salary filter.
    • Update instructor salaries using average and conditional logic.
    • Retrieve instructor data with filtering, ordering, limits, offsets, and aggregate functions.
  • Joins and Nested Queries

    • LEFT JOIN between employee and branch.
    • Nested query to get employees with total_sales > 30000.
    • Safe explicit INNER JOIN replacing NATURAL JOIN in complex query.
  • Triggers

    • triggertest: Inserts data into table2 on insert in table1.
    • sex_trigger: Conditional trigger for inserting a message into trigger_test based on employee sex.

    Changes

  • Fixed duplicate inserts and primary key conflicts.

  • Added PostgreSQL-compatible default values.

  • Replaced unsafe NATURAL JOIN with explicit INNER JOIN.

  • Ensured triggers reference existing tables.

@fahimahammed fahimahammed merged commit 97b0ab2 into fahimahammed:main Oct 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants