{"id":21747278,"url":"https://github.com/vgvr0/sql-complete-reference-basic-intermediate-advanced","last_synced_at":"2026-01-04T14:30:31.369Z","repository":{"id":233068032,"uuid":"785930967","full_name":"vgvr0/SQL-Complete-Reference-Basic-Intermediate-Advanced","owner":"vgvr0","description":"Commonly Used SQL Functions","archived":false,"fork":false,"pushed_at":"2024-05-06T12:29:01.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T22:53:45.300Z","etag":null,"topics":["interview-questions","sql","sql-advanced","sql-basics","sql-functions","sql-intermediate","sql-interview-questions"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vgvr0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-12T23:59:00.000Z","updated_at":"2024-07-01T12:20:58.000Z","dependencies_parsed_at":"2024-04-14T15:51:43.388Z","dependency_job_id":"5ffc91da-3311-4c37-8482-7fe7daea8fc4","html_url":"https://github.com/vgvr0/SQL-Complete-Reference-Basic-Intermediate-Advanced","commit_stats":null,"previous_names":["vgvr0/sql-resume"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgvr0%2FSQL-Complete-Reference-Basic-Intermediate-Advanced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgvr0%2FSQL-Complete-Reference-Basic-Intermediate-Advanced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgvr0%2FSQL-Complete-Reference-Basic-Intermediate-Advanced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgvr0%2FSQL-Complete-Reference-Basic-Intermediate-Advanced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vgvr0","download_url":"https://codeload.github.com/vgvr0/SQL-Complete-Reference-Basic-Intermediate-Advanced/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244722742,"owners_count":20499154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interview-questions","sql","sql-advanced","sql-basics","sql-functions","sql-intermediate","sql-interview-questions"],"created_at":"2024-11-26T08:08:31.993Z","updated_at":"2026-01-04T14:30:31.340Z","avatar_url":"https://github.com/vgvr0.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL functions\n\nThis repository contains examples of the main categories of SQL functions, including aggregation functions, string functions, date and time functions, comparison functions, logical functions, conversion functions, and system functions.\n\n## Content\n\n- [Aggregation functions](#aggregation-functions)\n- [String functions](#string-functions)\n- [Date and time functions](#date-and-time-functions)\n- [Comparison functions](#comparison-functions)\n- [Logical functions](#logical-functions)\n- [Conversion functions](#conversion-functions)\n- [System functions](#system-functions)\n- [Window-functions](#window-functions)\n  \n## Aggregation functions\nAggregation functions calculate summary values ​​from data sets.\n\nExample:\n```sql\nSELECT SUM(salary) FROM employees;\n```\nOther aggregation functions include:\n```sql\nSELECT AVG(price) FROM products;\nSELECT COUNT(DISTINCT customer_id) FROM orders;\nSELECT MAX(score) FROM exams;\nSELECT MIN(age) FROM users;\n```\n## String Functions\nString functions manipulate text strings.\n\nExample:\n```sql\nSELECT UPPER(name) FROM customers;\n```\nOther string functions include:\n```sql\nSELECT CONCAT(first_name, ' ', last_name) AS full_name FROM employees;\nSELECT SUBSTRING(phone_number, 1, 3) AS area_code FROM contacts;\nSELECT LENGTH(address) FROM locations;\nSELECT TRIM(LEADING ' ' FROM username) FROM accounts;\n```\n## Date and Time Functions\nThese functions work with date and time values.\n\nExample:\n```sql\nSELECT DATE(datetime_column) FROM events;\n```\nOther date and time functions include:\n```sql\nSELECT YEAR(hire_date) FROM employees;\nSELECT MONTH(birth_date) FROM students;\nSELECT CURRENT_TIMESTAMP();\nSELECT DATEDIFF(end_date, start_date) AS duration FROM projects;\n```\n## Comparison Functions\nComparison functions compare values and return boolean values (TRUE or FALSE).\n\nExample:\n```sql\nSELECT * FROM users WHERE age = 30;\n```\nOther comparison functions include:\n```sql\nSELECT * FROM products WHERE price \u003e 100;\nSELECT * FROM orders WHERE status \u003c\u003e 'Completed';\nSELECT * FROM employees WHERE hire_date BETWEEN '2020-01-01' AND '2020-12-31';\nSELECT * FROM customers WHERE name LIKE 'J%';\n```\n## Logical Functions\nLogical functions perform logical operations on boolean values.\n\nExample:\n```sql\nSELECT * FROM customers WHERE age \u003e 18 AND city = 'New York';\n```\nOther logical functions include:\n```sql\nSELECT * FROM orders WHERE status = 'Pending' OR status = 'Processing';\nSELECT * FROM students WHERE NOT graduated;\nSELECT * FROM products WHERE category IN ('Electronics', 'Clothing');\nSELECT * FROM users WHERE email IS NULL;\n```\n## Conversion Functions\nConversion functions convert values from one data type to another.\n\nExample:\n```sql\nSELECT CAST(quantity AS VARCHAR) FROM inventory;\n```\nOther conversion functions include:\n```sql\nSELECT CONVERT(price, DECIMAL(10,2)) FROM products;\nSELECT CAST(order_date AS DATE) FROM orders;\nSELECT CAST(is_active AS INTEGER) FROM users;\nSELECT CAST(CONCAT(first_name, ' ', last_name) AS CHAR(50)) FROM employees;\n```\n## System Functions\nSystem functions provide information about the system or database.\n\nExample:\n```sql\nSELECT USER();\n```\nOther system functions include:\n```sql\nSELECT DATABASE();\nSELECT VERSION();\nSELECT CURRENT_USER();\nSELECT LAST_INSERT_ID();\n```\n## Window Functions\nWindow functions perform calculations across a set of rows that are related to the current row.\n\nExample:\n```sql\nSELECT employee_id, department, salary, AVG(salary) OVER (PARTITION BY department) AS avg_department_salary FROM employees;\n```\nOther window functions include:\n```sql\nSELECT product_id, category, price, RANK() OVER (PARTITION BY category ORDER BY price DESC) AS price_rank FROM products;\nSELECT order_id, customer_id, order_date, LAG(order_date) OVER (PARTITION BY customer_id ORDER BY order_date) AS previous_order_date FROM orders;\nSELECT student_id, subject, score, DENSE_RANK() OVER (PARTITION BY subject ORDER BY score DESC) AS subject_rank FROM exam_results;\nSELECT sales_rep, order_date, sales_amount, SUM(sales_amount) OVER (PARTITION BY sales_rep ORDER BY order_date) AS running_total FROM sales;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgvr0%2Fsql-complete-reference-basic-intermediate-advanced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvgvr0%2Fsql-complete-reference-basic-intermediate-advanced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgvr0%2Fsql-complete-reference-basic-intermediate-advanced/lists"}