|
First
|
Prev |
Next
|
Last
Pages: 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
ResultSet Paging and count(*) performance Hi Ken, You can get the total record count by using the OVER keyword. For the code you provided, make changes like below. With Cust AS ( SELECT CustomerID, CompanyName, ROW_NUMBER() OVER (order by CompanyName) as RowNumber, COUNT(*) OVER () As TotalCount FROM Customers where Country in ('US', 'CN')) select *... 22 Jul 2008 12:41
select rowcount per group before value in group = null I need to select the top 3 rows per each group (xID -- order by xID). No problem here. But I need to select the count of rows in each group before a null value is encountered in the stat column -- ordering by xID CREATE TABLE #tmp1(rowID int Identity(1,1), xID int, x1 int, stat varchar(1)) INSERT INTO #tmp1... 22 Jul 2008 13:43
how to use SUM I'm not sure how I could get a total from multiple results. For example, this SQL: SELECT COUNT(id) AS [Total Dialup Customers] ,rgheader.rg_name AS [Rate Group] FROM customer INNER JOIN custrate ON custrate.custid = customer.id INNER JOIN rgheader ON rgheader.rg_id = custrate.rgid WHERE rgheader.rg_id I... 22 Jul 2008 12:41
Need help on how to write this report. Hi, Does anyone knows where can I get a script to generate backup and restore information like the one show below. I need to do this quick for my boss and can't think of a way to write this fast. Any helps would greatly appreciate. DatabaseName Backupstartat Backuptime Restoretime AvgFinishTime ----... 23 Jul 2008 05:05
SUM doesnt work I have tried this sql but rows where the "VD" is the same is not summed. What is the error ? SELECT (VD.perc * RIGHEDOCUMENTI.TOTNETTORIGA) / 100 AS VALUETOT, VD.VD, VD.perc, ANAGRAFICAARTICOLI.CODICE, RIGHEDOCUMENTI.NUMERODOC, sum ((VD.perc * RIGHEDOCUMENTI.TOTNETTORIGA) / 100) as pinco,RIGHEDOCUMENTI.CODART... 22 Jul 2008 14:45
Query Suggestions? I have a problem. I just inherited a program that is full of holes and bugs and I need to do some patching. Just to note everyone, I did not set up this database and I did not code this program, I am stuck with it as is. That being said, I have to do some checks on a database to make sure pairs of material are i... 22 Jul 2008 12:41
select from the middle with below query, i select top 5 top and bottom records from the table and then select a random record within selected top 10. --- set @selectedId = ( select top 1 id from ( select TOP 10 * from ( SELECT ROW_NUMBER() OVER(order by earned desc, spent asc, showed ... 22 Jul 2008 09:35
from a stored procedure: how to return datasets and their tabl Omid, Unfortunately I do not have an answer to your question. I found your post when searching for the same thing. What you want to do is not as outlandish as these other guys sugest. It is not unreasonable to want a collection of objects to be identifiable by name as well as by their ordinal. This is the c... 23 Jul 2008 13:18
SQL Help - linking tables based on date. I have 2 tables, A and B with a layout similar to the following: A PKId | data 1 | aa B FKId | year | data 1 | 2005 | xx 1 | 2006 | yy 1 | 2006 | zz What I am trying to do is join the 2 tables only for the minimum year (2005 in this case). So I would have re... 22 Jul 2008 11:39 |