jess Posted December 18, 2007 Share Posted December 18, 2007 hii'm having real toruble writing a query in sql which does a group by command and limits the response to be greater than 3. i've been told my query is wrong but i don't know why.SELECT Hoilday_code, Count(Code_of_hoildays)as RecordCount FROM Details_of_hoildayGroup by Hoilday_codeWhere Length(Code_of_hoildays)> 3;above is my query can anyone tell whats wrong with it because i'm really have no ideathanksjessica Link to comment Share on other sites More sharing options...
justsomeguy Posted December 18, 2007 Share Posted December 18, 2007 The Length function is using the field name, it should be using the alias for the count.SELECT Hoilday_code, Count(Code_of_hoildays)as RecordCount FROM Details_of_hoildayGroup by Hoilday_codeWhere Length(RecordCount)> 3; Link to comment Share on other sites More sharing options...
jess Posted December 19, 2007 Author Share Posted December 19, 2007 hithanks but i'm afraid it still doesn't workSELECT Hoilday_code, Count(Code_of_hoildays)as RecordCount FROM Details_of_hoildayGroup by Hoilday_codeWhere Length(RecordCount)> 3; Link to comment Share on other sites More sharing options...
Synook Posted December 19, 2007 Share Posted December 19, 2007 You have to put the WHERE before the GROUP BY SELECT Hoilday_code, Count(Code_of_hoildays)as RecordCountFROM Details_of_hoilday WHERE LENGTH(RecordCount) > 3GROUP BY Hoilday_code; Link to comment Share on other sites More sharing options...
jess Posted December 19, 2007 Author Share Posted December 19, 2007 hii've tried that and i've been told that its missing the missing right parenthesisSELECT Hoilday_code, Count(Code_of_hoildays)as RecordCountFROM Details_of_hoilday WHERE LENGTH(Code_of_hoildays as RecordCount)> 3GROUP BY Hoilday_code; Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2007 Share Posted December 19, 2007 This line isn't correct anymore, check the code above:WHERE LENGTH(Code_of_hoildays as RecordCount)> 3 Link to comment Share on other sites More sharing options...
jess Posted December 21, 2007 Author Share Posted December 21, 2007 hii;m sorry i'm new to this whats not correct?thanksjessica Link to comment Share on other sites More sharing options...
Synook Posted December 25, 2007 Share Posted December 25, 2007 ... try what I posted above SELECT Hoilday_code, Count(Code_of_hoildays)as RecordCountFROM Details_of_hoilday WHERE LENGTH(RecordCount) > 3GROUP BY Hoilday_code; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.