{"id":869,"date":"2011-03-28T04:57:03","date_gmt":"2011-03-28T09:57:03","guid":{"rendered":"http:\/\/www.dpriver.com\/blog\/?page_id=869"},"modified":"2015-07-23T23:54:03","modified_gmt":"2015-07-24T04:54:03","slug":"decoding-sql-grammar-select-statement","status":"publish","type":"page","link":"https:\/\/www.dpriver.com\/blog\/list-of-demos-illustrate-how-to-use-general-sql-parser\/decoding-sql-grammar-select-statement\/","title":{"rendered":"Decoding SQL grammar — select statement"},"content":{"rendered":"

This demo helps you fully take advantage of the general SQL parser to decode SQL grammar of select SQL statement.<\/p>\n

Take this SQL for example:<\/p>\n

    \r\nSELECT e.last_name      AS name,\r\n       e.commission_pct comm,\r\n       e.salary * 12    \"Annual Salary\"\r\nFROM   scott.employees AS e\r\nWHERE  e.salary > 1000\r\nORDER  BY\r\n  e.first_name,\r\n  e.last_name;\r\n<\/pre>\nSQL elements in select statement decoded by this demo:<\/p>\n\r\nSelect statement:\r\n\tSelect set type: none\r\n\r\nselect clause:\r\n\tColumns\r\n\t\tFullname:e.last_name\r\n\t\tPrefix:e\tColumn:last_name\talias:name\r\n\t\tFullname:e.commission_pct\r\n\t\tPrefix:e\tColumn:commission_pct\talias:comm\r\n\t\tFullname:e.salary * 12\r\n\t\tPrefix:\tColumn:e.salary * 12\talias:\"Annual Salary\"\r\n\r\nfrom clause:\r\n\tscott.employees as e\r\n\tschema: scott\r\n\tobject:  employees\r\n\ttablealias: e\r\n\t\r\nwhere clause:\r\n\te.salary > 1000\r\n\r\norder by clause:\r\n\te.first_name,\r\n\te.last_name\r\n<\/pre>\nIf Select SQL Statement with UNION, INTERSECT, and EXCEPT set operators, please check this document<\/a><\/p>\nDownload this demo: C# version<\/a>, Java version<\/a>, ANSI C demo<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"This demo helps you fully take advantage of the general SQL parser to decode SQL grammar of select SQL statement. Take this SQL for example: SELECT e.last_name AS name, e.commission_pct comm, e.salary * 12 “Annual Salary” FROM scott.employees AS e WHERE e.salary > 1000 ORDER BY e.first_name, e.last_name; SQL elements in select statement decoded by this demo: Select statement: Select set type: none select clause: Columns Fullname:e.last_name Prefix:e Column:last_name alias:name Fullname:e.commission_pct Prefix:e Column:commission_pct alias:comm Fullname:e.salary * 12 Prefix: Column:e.salary * 12 alias:”Annual Salary” from clause: scott.employees as e schema: scott object: employees tablealias: e where clause: e.salary > 1000 order\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":235,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"gsp_feature_page_tt.php","meta":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"yoast_head":"\nHelp you to make better use of General SQL Parser<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n