mysql - Group and order by a column but donot include that column in results -
i've been trying figure out how can modify query result set not include numhits. want same results in same order, not have numhits included.
select `newel_inventorykeywordiddictionaryid`.`inventoryid` ,count(`newel_inventorykeywordiddictionaryid`.`inventoryid`) numhits `newel_inventorykeywordiddictionaryid` , `newel_inventorydictionary` `newel_inventorykeywordiddictionaryid`.`dicid` = `newel_inventorydictionary`.`dicid` , ( `newel_inventorydictionary`.`word` = 'alabaster' or `newel_inventorydictionary`.`word` = 'chess' ) group inventoryid order numhits desc;
sample results:
inventoryid, numhits 6928, 2 6929, 2 6924, 2 6925, 2 13772, 2 6926, 2 18203, 1 6931, 1 13863, 1 18402, 1
desired results:
inventoryid 6928 6929 6924 6925 13772 6926 18203 6931 13863 18402
move column select clause order clause:
select `newel_inventorykeywordiddictionaryid`.`inventoryid` `newel_inventorykeywordiddictionaryid` , `newel_inventorydictionary` `newel_inventorykeywordiddictionaryid`.`dicid` = `newel_inventorydictionary`.`dicid` , ( `newel_inventorydictionary`.`word` = 'alabaster' or `newel_inventorydictionary`.`word` = 'chess' ) group inventoryid order count(`newel_inventorykeywordiddictionaryid`.`inventoryid`) desc;
Comments
Post a Comment