| Author |
Topic |
|
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2007-01-25 : 23:26:03
|
| hi all,how to count record rows found, no matter how is my sql statement structure is.. count(*) if i select all, but how to count result if there;s Group by clause, when i dont have unique key to represent each row? thanks in advance~~~Focus on problem, not solution~~~ |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-25 : 23:32:51
|
to count no of records in tableselect count(*) from tbl with group by clauseselect somecol, count(*) from tbl group by somecol Is this what you want ? KH |
 |
|
|
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2007-01-26 : 00:44:19
|
| ermm.. i dun think so, because that will return many rows with total.. i want it to count how many rows found by some sql query... like SELECT CustomLotNo, StorageID, FROM tblItemDetail dWHERE (ItemID = 'GCL243V1-ARH')GROUP BY CustomLotNo, StorageIDwill list the found rows, but how to return the total rows it found.~~~Focus on problem, not solution~~~ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-26 : 01:03:02
|
[code]Option 1 :SELECT CustomLotNo, StorageIDFROM tblItemDetail dWHERE (ItemID = 'GCL243V1-ARH')GROUP BY CustomLotNo, StorageIDselect @@rowcountOption 2 :select count(*)from( SELECT CustomLotNo, StorageID FROM tblItemDetail d WHERE (ItemID = 'GCL243V1-ARH') GROUP BY CustomLotNo, StorageID) aOption 3 :SELECT CustomLotNo, StorageID,count(*)FROM tblItemDetail dWHERE (ItemID = 'GCL243V1-ARH')GROUP BY CustomLotNo, StorageIDwith rollup[/code] KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-26 : 01:04:52
|
Option 4 :Do it in your front end application [(c) Copyright Madhivanan] KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-26 : 02:22:24
|
Before we get sued by Madhivanan, don't forget the copyright Peter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-26 : 02:23:51
|
Thanks for the reminder KH |
 |
|
|
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2007-01-26 : 03:58:19
|
| thank you so much guys..For sure option 2 works the way i want it to..unfortunately option 1 and 3 cannot, it didnt returns total row, it returns the rows itself.. it's just that i wonder if there's special function to perform this... apparently got to do like the old method.. (option2)~~~Focus on problem, not solution~~~ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-26 : 04:07:13
|
[code]Option 1 :SELECT CustomLotNo, StorageIDFROM tblItemDetail dWHERE (ItemID = 'GCL243V1-ARH')GROUP BY CustomLotNo, StorageIDselect @@rowcount[/code]the total rows is return from the @@rowcountOption 3 will required a bit more work as the total count is in the result sets.Any not Option 4 ? (Do you know I have to pay the copyright fee to quote that ) KH |
 |
|
|
|