[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572774-105":53,"doc-detail-572774-en":127},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","sql-for-data-analysis-cheat-sheet-quick-reference","SQL for Data Analysis Cheat Sheet - Quick reference","","SQL for Data Analysis Cheat Sheet provides a concise reference for querying relational databases using Structured Query Language. It covers core data retrieval with SELECT and FROM, filtering with WHERE, pattern matching with LIKE, null handling, and aggregation with GROUP BY, aggregate functions, and HAVING. It also explains sorting with ORDER BY, basic computations and rounding, common integer-division pitfalls, join concepts, and data-modification commands (INSERT, UPDATE, DELETE). Date and time formats and current date/time functions are included.",{"@graph":63,"@context":119},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":51,"@type":70,"position":76},"https://docshare.wps.com/template/general/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/sql-for-data-analysis-cheat-sheet-quick-reference/572774/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/sql-for-data-analysis-cheat-sheet-quick-reference/572774.png","ImageObject",442,249,{"name":88,"@type":89},"Bulrr","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",8,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"How do you select specific columns and rows from a table in SQL?","Question",{"text":109,"@type":110},"Use SELECT to list columns, FROM to name the table, and WHERE to filter rows. Example patterns include SELECT id, name FROM product and SELECT name FROM product WHERE price > 15.","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"How do GROUP BY, HAVING, and aggregate functions work together?",{"text":114,"@type":110},"Use aggregate functions like COUNT, MIN/MAX, SUM, or AVG within a GROUP BY clause to compute per-group results. Apply HAVING to filter groups based on aggregated values, such as HAVING AVG(price) > 3.0.",{"name":116,"@type":107,"acceptedAnswer":117},"What causes integer division issues in PostgreSQL and SQL Server, and how can you fix it?",{"text":118,"@type":110},"When both operands are integers, the / operator performs integer division and truncates decimals. Cast one operand to a decimal type before dividing, e.g., CAST(123 AS decimal) / 2.","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},572774,1792083779,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":50,"category_name":51,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":76,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":9},5909892115043,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","SQL for Data Analysis Cheat Sheet   \nSQL  \nSQL, or Structured Query Language, is a language for talking to databases. It lets you select specific data and build complex reports. Today, SQL is a universal language of data, used in practically all technologies that process data.  \nSELECT  \nFetch the id and name columns from the product table: SELECT id , name  \nFROM product;  \nConcatenate the name and the description to fetch the full description of the products:  \nSELECT name || ' - ' || description FROM product;  \nFetch names of products with prices above 15:  \nSELECT name  \nFROM product WHERE price > 15;  \nFetch names of products with prices between 50 and 150: SELECT name  \nFROM product  \nWHERE price BETWEEN 50 AND 150;  \nFetch names of products that are not watches: SELECT name  \nFROM product  \nWHERE name ! = 'watch ' ;  \nFetch names of products that start with a 'P ' or end with an'  \ns ':  \nSELECT name FROM product  \nWHERE name LIKE 'P% ' OR name LIKE '%s ' ;  \nFetch names of products that start with any letter followed by' rain ' (like 'train ' or 'grain '):  \nSELECT name FROM product  \nWHERE name LIKE '_ rain ' ;  \nFetch names of products with non-null prices: SELECT name  \nFROM product  \nWHERE price IS NOT NULL;  \nGROUP BY  \n\n| PRODUCT |  |\n| --- | --- |\n| name | category |\n| Knife | Kitchen |\n| Pot | Kitchen |\n| Mixer | Kitchen |\n| Jeans | Clothing |\n| Sneakers | Clothing |\n| Leggings | Clothing |\n| Smart TV | Electronics |\n| Laptop | Electronics |\n\nAGGREGATE FUNCTIONS  \nCount the number of products:  \nSELECT COUNT(* )  \nFROM product;  \nCount the number of products with non-null prices: SELECT COUNT(price)  \nFROM product;  \nCount the number of unique category values:  \nSELECT COUNT(DISTINCT category)  \nFROM product;  \nGet the lowest and the highest product price:  \nSELECT MIN(price) , MAX(price)  \nFROM product;  \nFind the total price of products for each category:  \nSELECT category , SUM(price) FROM product  \nGROUP BY category;  \nFind the average price of products for each category whose average is above 3.0:  \nSELECT category , AVG(price) FROM product  \nGROUP BY category  \nHAVING AVG(price) > 3 .0 ;  \nORDER BY  \nFetch product names sorted by the price column in the default ASCending order:  \nSELECT name FROM product  \nORDER BY price [ASC];  \nFetch product names sorted by the price column in DESCending order:  \nSELECT name FROM product  \nORDER BY price DESC;  \nCOMPUTATIONS  \nUse +, -, *, / to do basic math. To get the number of seconds in a week:  \nSELECT 60 * 60 * 24 * 7 ;  \n- - result: 604800  \nROUNDING NUMBERS  \nRound a number to its nearest integer:  \nSELECT ROUND (1234 .56789) ;  \n- - result: 1235  \nRound a number to two decimal places:  \nSELECT ROUND (AVG (price) , 2 ) FROM product  \nWHERE category_id = 21;  \n- - result: 124 .56  \nTROUBLESHOOTING INTEGER DIVISION  \nIn PostgreSQL and SQL Server, the / operator performs integer division for integer arguments. If you do not see the number of decimal places you expect, it is because you are dividing between two integers. Cast one to decimal:  \n123 / 2 - - result: 61  \nCAST(123 AS decimal) / 2 - - result: 61 .5  \nDIVISION BY 0  \nTo avoid this error, make sure the denominator is not 0. You may use the NULLIF () function to replace 0 with a NULL, which results in a NULL for the entire expression:  \ncount / NULLIF(count_all , 0 )  \nJOIN  \nJOIN is used to fetch data from multiple tables. To get the names of products purchased in each order, use:  \nSELECT  \norders .order_date , [product.name](product.name) AS product, amount  \nFROM orders JOIN product  \nON [product.id = orders.product_id](product.id = orders.product_id);  \nLearn more about JOINs in our interactive SQL JOINs course.  \nINSERT  \nTo insert data into a table, use the INSERT command: INSERT INTO category  \nVALUES  \n(1 , 'Home and Kitchen ' ) ,  \n(2 , 'Clothing and Apparel ' ) ;  \nYou may specify the columns to which the data is added. The remaining columns are filled with predefined default values or NULLs.  \nI","cbCaibDfPpOVtGXZ","https://ap.wps.com/l/cbCaibDfPpOVtGXZ","pdf",144110,"English","# SELECT and Filtering\n## SELECT with FROM\n## Concatenation and WHERE conditions\n## NULL checks and LIKE pattern matching\n# Aggregations and Sorting\n## Aggregate functions with GROUP BY\n## HAVING for aggregated filters\n## ORDER BY with ASC and DESC\n# Computations and Rounding\n## Basic arithmetic operators\n## ROUND for integers and decimals\n# Troubleshooting\n## Integer division casting in PostgreSQL/SQL Server\n## Preventing division by 0 with NULLIF\n# JOIN and Data Modification\n## JOIN across multiple tables\n## INSERT\n## UPDATE\n## DELETE\n# Date and Time\n## Date, time, and timestamp types\n## Current date/time functions\n## Creating date and time values","[{\"question\":\"How do you select specific columns and rows from a table in SQL?\",\"answer\":\"Use SELECT to list columns, FROM to name the table, and WHERE to filter rows. Example patterns include SELECT id, name FROM product and SELECT name FROM product WHERE price \\u003e 15.\"},{\"question\":\"How do GROUP BY, HAVING, and aggregate functions work together?\",\"answer\":\"Use aggregate functions like COUNT, MIN/MAX, SUM, or AVG within a GROUP BY clause to compute per-group results. Apply HAVING to filter groups based on aggregated values, such as HAVING AVG(price) \\u003e 3.0.\"},{\"question\":\"What causes integer division issues in PostgreSQL and SQL Server, and how can you fix it?\",\"answer\":\"When both operands are integers, the / operator performs integer division and truncates decimals. Cast one operand to a decimal type before dividing, e.g., CAST(123 AS decimal) / 2.\"}]","SQL for Data Analysis Cheat Sheet - Quick reference | PDF",1791929210]