lulu50
asked on
SQL (Group by)
Hi,
I have a select statement that I just want to group by
EditTime and AppID
instead of grouping by
EditTime
, AppID
, AppName
, MajorUpgradeCost
, PlannedUpgradeYear
, UpgradeStrategy
, SoftwareVersion
, OldestVersionSupportedBySu pplier
, EmployeeName
but I do want to select all the above field but I just want to group by the "EditTime" and "AppID"
How can I do this?
I have a select statement that I just want to group by
EditTime and AppID
instead of grouping by
EditTime
, AppID
, AppName
, MajorUpgradeCost
, PlannedUpgradeYear
, UpgradeStrategy
, SoftwareVersion
, OldestVersionSupportedBySu
, EmployeeName
but I do want to select all the above field but I just want to group by the "EditTime" and "AppID"
How can I do this?
SELECT
EditTime
, AppID
, AppName
, MajorUpgradeCost
, PlannedUpgradeYear
, UpgradeStrategy
, SoftwareVersion
, OldestVersionSupportedBySupplier
, EmployeeName
FROM EDIT_ApplicationDescription
WHERE ((datalength(SoftwareVersion)!=0) and ((SoftwareVersion != '') or (SoftwareVersion IS NOT NULL) or (SoftwareVersion <> '')))
or
((datalength(MajorUpgradeCost)!=0) and ((MajorUpgradeCost != '') or (MajorUpgradeCost IS NOT NULL) or (MajorUpgradeCost <> '')))
or
((datalength(PlannedUpgradeYear)!=0) and ((PlannedUpgradeYear != '') or (PlannedUpgradeYear IS NOT NULL) or (PlannedUpgradeYear <> '')))
or
((datalength(UpgradeStrategy)!=0) and ((UpgradeStrategy != '') or (UpgradeStrategy IS NOT NULL) or (UpgradeStrategy <> '')))
or
((datalength(OldestVersionSupportedBySupplier)!=0) and ((OldestVersionSupportedBySupplier != '') or (OldestVersionSupportedBySupplier IS NOT NULL)
or (OldestVersionSupportedBySupplier <> '')))
group by AppID, EditTime, AppName
, MajorUpgradeCost
, PlannedUpgradeYear
, UpgradeStrategy
, SoftwareVersion
, OldestVersionSupportedBySupplier
, EmployeeName
order by EditTime desc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Scott!!!
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for lulu50's comment #a40504423
for the following reason:
Thanks
Accepted answer: 0 points for lulu50's comment #a40504423
for the following reason:
Thanks
ASKER
Thank you
Just a thought, I don't see any aggregate functions like SUM(), MIN(), MAX(), COUNT(), etc., so why are we grouping in the first place?
If you only want to return unique rows, change SELECT to SELECT DISTINCT.
If there's something else you need, spell it out in this question, specifically 'I want to do {x} with {all columns other than {"EditTime" and "AppID"}'