It is not clear what SQL Syntax you are using.
Remember that your SQL Syntax needs to match the database from which you are getting your data. The Foxpro SQL Syntax is slightly non-standard and different from the MySQL SQL Syntax.
Your posting tags: mysql sql foxpro dbase
include Foxpro, so can I assume that you are using the FP SQL Syntax to query Foxpro data tables?
I want two gst row
If I understand what you are wanting, it seems as though you want the gst for "P" results in one row and the gst for "G" results in a separate row.
If you are getting your data from a Foxpro data table, then you might consider something like the following:
SELECT (SSTA*2)as gst, IIF(Flg = "P","P","G") as SortFlg, sum(SSTAAMO) as gstamo FROM DIS WHERE FLG $ "P,G" GROUP BY 1,2
Introducing the added field SORTFLG and making it (the #2 field) part of the GROUP BY statement, will force the results for "P" and "G" into separate result rows. You can always remove that extra field later if desired.
If you are getting your data from another database with SQL Syntax that does not support the IIF() syntax, you can use the CASE syntax to create your new SORTFLG.
EDIT: Why I didn't think of it before, I have no idea. Regardless, you don't need the IIF() syntax at all. You can still introduce the new, 2nd field SORTFLG but instead of using the IIF() command, you can use the FLG field alone, but make sure that you include in into your GROUP BY line so that your result will have a separate "P" record and "G" record.
SELECT (SSTA*2)as gst, Flg as SortFlg, sum(SSTAAMO) as gstamo FROM DIS WHERE FLG $ "P,G" GROUP BY 1,2
Good Luck