SQL MIN() And GROUP BY Help Appreciated
Nov 17, 2006
g'day gents,
I run a select query against my mysql database using asp.net. The query looks like this:
SELECT distinct(rubbet.ortnamn) as Bebyggelsenamn, count(rubbet.ortnamn) as 'Antal',min(rubbet.artal) as Beläggsår, rubbet.belaggsform as Beläggsform, rubbet.harad as Härad, rubbet.socken as Socken, rubbet.ovrigt as Övrigt, rubbet.filnamn as Filnamn, rubbet.path as Sökväg FROM rubbet WHERE rubbet.ortnamn like '%" + searchTextBox.Text + "%' and rubbet.harad like '" + DropDownList1.SelectedValue + "' and rubbet.socken like '" + DropDownList2.SelectedValue + "' and rubbet.ovrigt like '" + ovrigtRadioButtonList.SelectedValue + "' group by Bebyggelsenamn ORDER BY '" + sorteraDropDownList.SelectedValue + "' " + ordning + ";
The query works just fine and runs smoothly. I only have one problem. If a user types for example monkey in the 'searchTextBox' the database finds all the instances of monkey, counts them and presents one line that states:
Monkey, 138 instances, bla bla bla
my problem is with the Min aggregate function. It selects the lowest rubbet.artal for Monkey but I want rubbet.belaggsform to get the data from the same row as Min(rubbet.artal) gets the data from. As it is now, rubbet.belaggsform selects its data from the row with the lowest primary key.
For example the result could look like the following:
Holmagården, 127, , 1873
when it should say:
Holmagården, 127, Holmagaard, 1873
I'm only presenting the columns above, the rest of them are for creating links and what not.
I guess I should write a sub query of some kind to pick the correct rubbet.belaggsform that corresponds to MIN(rubbet.artal) together with the other factors but I just can't get it to work.
Help me out here please.
View 2 Replies
ADVERTISEMENT
Mar 21, 2000
How would I make something like this work?
CREATE TRIGGER [tr_update_doc_count] ON [Documents]
FOR INSERT
AS
[Declared variables]
[I want to get the tablereference from the inserted information]
SELECT @tableref = Table_id, @Account_id = Account_id from inserted
[Then I get the Actual Table Name from the UsercreatedTables Table where it is stored]
SELECT @tablename = TableName from UsercreatedTables WHERE Table_id = @tableref
[Now I want to use the @tablename I got from UsercreatedTables in the query]
SELECT @Current_Doc_Count = Account_Docs from @tablename WHERE Account_id = @Account_id
I am not sure how to get it to use the variable @tablename for the table name in the last query.
It gives me an error stating that @tablename is invalid syntax.
Any help is much appreciated!
View 1 Replies
View Related
Aug 26, 2002
Server: Msg 9004, Level 21, State 1, Line 1
The log for database ' ' is corrupt.
Connection Broken
How do i continue to perform a successful restore if one of the logs is corrupt? do i perform dbcc?
View 2 Replies
View Related
May 2, 2007
Hi,
Situation: I have a web application that is running on a server. IT has told me that the application I developed is taking up enormous amount of ram. It seems that the amount of ram that is taken up, is slowly increasing. About 10 megs per hour (memory leak). Furthermore, he has informed me that the ram is taken up by the sql. My senior developer told me that I probably have sqlconnections open that are not closed. I have checked through the application and it seems they are all closed properly. But I may have missed some, as the application is pretty big.
Questions:
1. Is there an application or piece of code that can monitor how many sql connections I have open during runtime?
2. Could there be any other common causes to such a kind of memory leak.
Any help with this matter would be very much appreciated.
Thank you for your time.
Sincerely,
Jeff
View 7 Replies
View Related
Jan 3, 2008
Hi everybody.I'm having difficulties with a button handler I put together from a few examples around the internet.Here's my code: <script runat="server"> Sub Add_To_Cart(ByVal Src As Object, ByVal Args As EventArgs) Dim FVArtikel_id As Label = FormViewDisplay.FindControl("Artikel_idLabel") Dim FVArtikel_naam As Label = FormViewDisplay.FindControl("Artikel_naamLabel") Dim FVArtikel_prijs As Label = FormViewDisplay.FindControl("Artikel_prijsLabel") Dim DBConnection As OleDbConnection Dim DBCommand As OleDbCommand Dim SQLString As String Dim SQLAddString As String If Not Session("sid") Is Nothing Then DBConnection = New OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:Documents and SettingsAdministratorBureaublad2ehandslego.nldatadb.mdb") DBConnection.Open() SQLString = "SELECT Count(*) FROM Orders WHERE sid = '" & CType(Session("sid"), String) & "' AND Artikel_id = '" & FVArtikel_id.Text & "'" DBCommand = New OleDbCommand(SQLString, DBConnection) DBCommand.Parameters.AddWithValue("@sid", Session("sid")) 'string? DBCommand.Parameters.AddWithValue("@Artikel_id", FVArtikel_id.Text) 'string? If DBCommand.ExecuteScalar() = 0 Then SQLAddString = "INSERT INTO Orders (sid, Order_datum, " & _ "Artikel_id, Order_artikel, Order_prijs, Order_hoeveelheid) VALUES (" & _ "'" & Session("sid") & "', " & _ "'" & Today & "', " & _ "'" & FVArtikel_id.Text & "', " & _ "'" & FVArtikel_naam.Text & "', " & _ "'" & FVArtikel_prijs.Text & "', 1)" DBCommand = New OleDbCommand(SQLAddString, DBConnection) DBCommand.Parameters.AddWithValue("@sid", Session("sid")) 'string? DBCommand.Parameters.AddWithValue("@Artikel_id", FVArtikel_id.Text) 'string? DBCommand.Parameters.AddWithValue("@Artikel_naam", FVArtikel_naam.Text) DBCommand.Parameters.AddWithValue("@Artikel_prijs", FVArtikel_prijs.Text) 'string? DBCommand.ExecuteNonQuery() End If DBConnection.Close() Src.Text = "Item Added" Src.ForeColor = Color.FromName("#990000") Src.BackColor = Color.FromName("#E0E0E0") Src.Font.Bold = True End If End Sub</script> I'm not getting any errors, it seems to me that i'm not getting a 'sid' value passed along but i don't know what to do about it.I've also already tried step debugging. This is my last resort. I hope you can help me.
View 3 Replies
View Related
May 10, 2007
I have a database with a dozen or so tables. No table constraints. Logic is all in stored procedures.
I have several Excel spreadsheets of data to import into the database, one speadsheet to a table. Each spreadsheet has additional data(columns) that each table has no interest in and should be ignored.
I would appreciate your thoughts on methods and best practices for loading this data to the database.
I am about to investigate SQL Server 2005 Express handling of XML. I am familiar with XML and XSL conversions and it seems to me that XSL conversion of Excel data to XML gives me a lot of flexibility prior to database import for shaping the data.
In short, importing data to the database from an XML source.
I am not famliar with SQL Server's XML capability and would appreciate thoughts on this while I look into it.
And of course alternate ways that I am overlooking.
Thanks
View 4 Replies
View Related
Sep 25, 2007
Hi, sorry if this is not the right place to post, any help or direction would be appreciated. I'm using SQLServer2005.
I'm having trouble writing a query and could do with some help. I'll illustrate the problem with an example.
Say I have 2 tables.
Table 1 - tbl_news:
ID
NewsTitle
linkedDoc1
linkedDoc2
1
my news title
5
3
Table 2 - tbl_docs:
ID
docTitle
1
doc1
2
doc2
3
doc3
4
doc4
5
doc5
Now, I'd like to write a query which returns bascially the first table, but which gets the doc title from table 2 using the IDs....how would I write this?
The end table would look like this:
ID
NewsTitle
linkedDoc1
linkedDoc2
1
my news title
doc5
doc3
Thanks so much!!
View 13 Replies
View Related
Mar 24, 2008
Hi,
Im a Jr DBA and have been given an assignment by my lead to find information on the following.
We are to migrate existing db of size 4TB to a
DELL PowerEdge 2950[Mem:Up to 32GB]
OS : Windows Server 2003 Std Edition X64 SP2
DB : SQL Server Enterprise Edition x64
I am to find on how to design the db to provide optimum performance,fail over and consider the growing factor of the db.
1)What would be the recommended RAID settings?
2)Placement of the tempdb ?
3)Should we do clustering and why ?
4)What Data partioning would do to help?
5)Any Other aspects to be considered for sizing db ?
6)Placement of data files and log file on separate physical disk ?
7)Indexing?
I have read many sites.I would appreaciate if someone could write suggestions and opinions based on their current db design spec or previous experience,by selecting best db design points.Thank You.
View 8 Replies
View Related
May 10, 2006
Hi -- I am fairly new to SSIS development, although I am starting to appreciate it more an more, especially since I have started getting into extending the object model. Here's my question:
I have a data flow that pulls data from any number of different delimited files with different numbers of columns. I have had no problem dealing with setting up run-time file locations and file names by using the expressions of a flat file data source, and i have been able to pretty easily deal with varying file delimiters by standardizing the files before they get into the data flow. however, I have not been able to come up with a solution that will allow my data source to discover its column info at run time, and then pass that information on to the data flow task. all i really care about is being able to properly parse the individual rows into individual column data by the flat file data source because the data flow itself is able to discover the actual data that the columns hold at run-time.
i would very much appreciate any feedback from anyone on possible solutions for this.
thanks!
View 1 Replies
View Related
Nov 17, 2007
I have the MS SQL2000 database failed to recover at computer restart. Now the database is marked suspect. How can I manage to recover the data?
Thank you.
View 5 Replies
View Related
Jul 20, 2005
It's arriving from ebuyer tomorrow for 32 quid. I already have aninstance of MSDE running on the laptop and ideally i would like SQLserver to be installed and use the current instance and not installany other additional services. [hope i got my terminology correcthere.] Basically all i would like is to use the Enterprise Managerwith my existing MSDE database. I was wondering if there is anything ishould be doing before I install. Should i shut down the service orleave it running for instance.Thanks for any tips,AndyB
View 2 Replies
View Related
Jan 3, 2007
SQL 2000 to SQL 2005 Upgrade Error - Database Down - Help Appreciated
I am upgrading a SQL 2000 standard database server to SQL 2005 standard on a windows 2003 server
I am logged in as domain admin and started the upgrade as 'sa'
The upgrade stops with the error:
Service MSSQLSERVICE can not be started. Verify you have sufficient privilages to start system services. The error code is (17185)
The error log shows:
2007-01-04 15:59:38.77 Server Authentication mode is MIXED.
2007-01-04 15:59:38.79 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
2007-01-04 15:59:38.79 Server (c) 2005 Microsoft Corporation.
2007-01-04 15:59:38.79 Server All rights reserved.
2007-01-04 15:59:38.79 Server Server process ID is 4188.
2007-01-04 15:59:38.79 Server Logging SQL Server messages in file 'F:SQLDataMSSQLlogERRORLOG'.
2007-01-04 15:59:38.79 Server This instance of SQL Server last reported using a process ID of 2980 at 1/4/2007 3:56:58 PM (local) 1/4/2007 2:56:58 AM (UTC). This is an informational message only; no user action is required.
2007-01-04 15:59:38.79 Server Registry startup parameters:
2007-01-04 15:59:38.79 Server -d F:SQLDataMSSQLdatamaster.mdf
2007-01-04 15:59:38.79 Server -e F:SQLDataMSSQLlogERRORLOG
2007-01-04 15:59:38.79 Server -l F:SQLDataMSSQLdatamastlog.ldf
2007-01-04 15:59:38.79 Server Command Line Startup Parameters:
2007-01-04 15:59:38.79 Server -s MSSQLSERVER
2007-01-04 15:59:38.79 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2007-01-04 15:59:38.79 Server Detected 4 CPUs. This is an informational message; no user action is required.
2007-01-04 15:59:38.83 Server Set AWE Enabled to 1 in the configuration parameters to allow use of more memory.
2007-01-04 15:59:39.02 Server Using the static lock allocation specified in the locks configuration option. Allocated 20000 Lock blocks and 20000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2007-01-04 15:59:39.02 Server Multinode configuration: node 0: CPU mask: 0x0000000a Active CPU mask: 0x0000000a. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2007-01-04 15:59:39.04 Server Multinode configuration: node 1: CPU mask: 0x00000005 Active CPU mask: 0x00000005. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2007-01-04 15:59:39.04 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2007-01-04 15:59:41.04 Server Attempting to recover in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2007-01-04 15:59:41.04 Server Database Mirroring Transport is disabled in the endpoint configuration.
2007-01-04 15:59:41.04 spid7s Starting up database 'master'.
2007-01-04 15:59:41.05 spid7s 1 transactions rolled forward in database 'master' (1). This is an informational message only. No user action is required.
2007-01-04 15:59:41.07 spid7s 0 transactions rolled back in database 'master' (1). This is an informational message only. No user action is required.
2007-01-04 15:59:41.07 spid7s Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2007-01-04 15:59:41.08 spid7s SQL Trace ID 1 was started by login "sa".
2007-01-04 15:59:41.08 spid7s Starting up database 'mssqlsystemresource'.
2007-01-04 15:59:41.11 spid7s Using 'dbghelp.dll' version '4.0.5'
2007-01-04 15:59:41.11 spid7s ***Stack Dump being sent to F:SQLDataMSSQLLOGSQLDump0035.txt
2007-01-04 15:59:41.11 spid7s SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
2007-01-04 15:59:41.11 spid7s * *******************************************************************************
2007-01-04 15:59:41.11 spid7s *
2007-01-04 15:59:41.11 spid7s * BEGIN STACK DUMP:
2007-01-04 15:59:41.11 spid7s * 01/04/07 15:59:41 spid 7
2007-01-04 15:59:41.11 spid7s *
2007-01-04 15:59:41.11 spid7s *
2007-01-04 15:59:41.11 spid7s * Exception Address = 78144D3A Module(MSVCR80+00014D3A)
2007-01-04 15:59:41.11 spid7s * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
2007-01-04 15:59:41.11 spid7s * Access Violation occurred reading address 0000001E
2007-01-04 15:59:41.11 spid7s *
2007-01-04 15:59:41.11 spid7s *
2007-01-04 15:59:41.11 spid7s * MODULE BASE END SIZE
2007-01-04 15:59:41.11 spid7s * sqlservr 01000000 02BA7FFF 01ba8000
2007-01-04 15:59:41.11 spid7s * ntdll 7C800000 7C8BFFFF 000c0000
2007-01-04 15:59:41.11 spid7s * kernel32 77E40000 77F41FFF 00102000
2007-01-04 15:59:41.11 spid7s * MSVCR80 78130000 781CAFFF 0009b000
2007-01-04 15:59:41.11 spid7s * msvcrt 77BA0000 77BF9FFF 0005a000
2007-01-04 15:59:41.11 spid7s * MSVCP80 7C420000 7C4A6FFF 00087000
2007-01-04 15:59:41.11 spid7s * ADVAPI32 77F50000 77FEBFFF 0009c000
2007-01-04 15:59:41.11 spid7s * RPCRT4 77C50000 77CEEFFF 0009f000
2007-01-04 15:59:41.11 spid7s * USER32 77380000 77411FFF 00092000
2007-01-04 15:59:41.11 spid7s * GDI32 77C00000 77C47FFF 00048000
2007-01-04 15:59:41.11 spid7s * CRYPT32 761B0000 76242FFF 00093000
2007-01-04 15:59:41.11 spid7s * MSASN1 76190000 761A1FFF 00012000
2007-01-04 15:59:41.11 spid7s * Secur32 76F50000 76F62FFF 00013000
2007-01-04 15:59:41.11 spid7s * MSWSOCK 71B20000 71B60FFF 00041000
2007-01-04 15:59:41.11 spid7s * WS2_32 71C00000 71C16FFF 00017000
2007-01-04 15:59:41.11 spid7s * WS2HELP 71BF0000 71BF7FFF 00008000
2007-01-04 15:59:41.11 spid7s * USERENV 76920000 769E3FFF 000c4000
2007-01-04 15:59:41.11 spid7s * opends60 333E0000 333E6FFF 00007000
2007-01-04 15:59:41.11 spid7s * NETAPI32 71C40000 71C97FFF 00058000
2007-01-04 15:59:41.11 spid7s * SHELL32 7C8D0000 7D0D2FFF 00803000
2007-01-04 15:59:41.11 spid7s * SHLWAPI 77DA0000 77DF1FFF 00052000
2007-01-04 15:59:41.11 spid7s * comctl32 77420000 77522FFF 00103000
2007-01-04 15:59:41.11 spid7s * psapi 76B70000 76B7AFFF 0000b000
2007-01-04 15:59:41.11 spid7s * instapi 48060000 48069FFF 0000a000
2007-01-04 15:59:41.11 spid7s * sqlevn70 4F610000 4F7A0FFF 00191000
2007-01-04 15:59:41.11 spid7s * SQLOS 344D0000 344D4FFF 00005000
2007-01-04 15:59:41.11 spid7s * rsaenh 68000000 6802EFFF 0002f000
2007-01-04 15:59:41.11 spid7s * AUTHZ 76C40000 76C53FFF 00014000
2007-01-04 15:59:41.11 spid7s * MSCOREE 61FB0000 61FF4FFF 00045000
2007-01-04 15:59:41.11 spid7s * ole32 77670000 777A3FFF 00134000
2007-01-04 15:59:41.11 spid7s * msv1_0 76C90000 76CB6FFF 00027000
2007-01-04 15:59:41.11 spid7s * iphlpapi 76CF0000 76D09FFF 0001a000
2007-01-04 15:59:41.11 spid7s * kerberos 62220000 62277FFF 00058000
2007-01-04 15:59:41.11 spid7s * cryptdll 766E0000 766EBFFF 0000c000
2007-01-04 15:59:41.11 spid7s * schannel 76750000 76776FFF 00027000
2007-01-04 15:59:41.11 spid7s * COMRES 77010000 770D5FFF 000c6000
2007-01-04 15:59:41.11 spid7s * XOLEHLP 622E0000 622E5FFF 00006000
2007-01-04 15:59:41.11 spid7s * MSDTCPRX 622F0000 62367FFF 00078000
2007-01-04 15:59:41.11 spid7s * msvcp60 780C0000 78120FFF 00061000
2007-01-04 15:59:41.11 spid7s * MTXCLU 62370000 62388FFF 00019000
2007-01-04 15:59:41.11 spid7s * VERSION 77B90000 77B97FFF 00008000
2007-01-04 15:59:41.11 spid7s * WSOCK32 71BB0000 71BB8FFF 00009000
2007-01-04 15:59:41.11 spid7s * OLEAUT32 77D00000 77D8BFFF 0008c000
2007-01-04 15:59:41.11 spid7s * CLUSAPI 62390000 623A1FFF 00012000
2007-01-04 15:59:41.11 spid7s * RESUTILS 623B0000 623C2FFF 00013000
2007-01-04 15:59:41.11 spid7s * DNSAPI 76ED0000 76EF8FFF 00029000
2007-01-04 15:59:41.11 spid7s * winrnr 76F70000 76F76FFF 00007000
2007-01-04 15:59:41.11 spid7s * WLDAP32 76F10000 76F3DFFF 0002e000
2007-01-04 15:59:41.11 spid7s * rasadhlp 76F80000 76F84FFF 00005000
2007-01-04 15:59:41.11 spid7s * security 62800000 62803FFF 00004000
2007-01-04 15:59:41.11 spid7s * dbghelp 671B0000 672C7FFF 00118000
2007-01-04 15:59:41.11 spid7s *
2007-01-04 15:59:41.11 spid7s * Edi: 62FA0040: 62FA0028 671AFFF0 00000000 00000000 00000000 00000000
2007-01-04 15:59:41.11 spid7s * Esi: 0000001E:
2007-01-04 15:59:41.11 spid7s * Eax: 0416C05E: C0400096 C0400416 00000416 000062FA 00000000 00000000
2007-01-04 15:59:41.11 spid7s * Ebx: 0416C040: 0105F270 00002000 00000005 00000000 3368C1E0 00000000
2007-01-04 15:59:41.11 spid7s * Ecx: 0105B010: 458B0046 01F88348 00D3850F 458B0000 89C23B50 0F342444
2007-01-04 15:59:41.11 spid7s * Edx: 00000000:
2007-01-04 15:59:41.11 spid7s * Eip: 78144D3A: 24FFA5F3 144E5495 C78B9078 000003BA 04E98300 E0830C72
2007-01-04 15:59:41.11 spid7s * Ebp: 33D6E770: 33D6E790 01C65B97 62FA0040 0000001E 0416C040 0416C6DC
2007-01-04 15:59:41.11 spid7s * SegCs: 0000001B:
2007-01-04 15:59:41.11 spid7s * EFlags: 00010212: 0020006D 00690046 0065006C 005C0073 006F0043 006D006D
2007-01-04 15:59:41.11 spid7s * Esp: 33D6E768: 62FA0040 33D6E7A4 33D6E790 01C65B97 62FA0040 0000001E
2007-01-04 15:59:41.11 spid7s * SegSs: 00000023:
2007-01-04 15:59:41.11 spid7s * *******************************************************************************
2007-01-04 15:59:41.11 spid7s * -------------------------------------------------------------------------------
2007-01-04 15:59:41.11 spid7s * Short Stack Dump
2007-01-04 15:59:41.13 spid7s 78144D3A Module(MSVCR80+00014D3A)
2007-01-04 15:59:41.13 spid7s 01C65B97 Module(sqlservr+00C65B97)
2007-01-04 15:59:41.13 spid7s 01CA43B5 Module(sqlservr+00CA43B5)
2007-01-04 15:59:41.13 spid7s 01CA452E Module(sqlservr+00CA452E)
2007-01-04 15:59:41.13 spid7s 0217D3BD Module(sqlservr+0117D3BD)
2007-01-04 15:59:41.13 spid7s 0217B896 Module(sqlservr+0117B896)
2007-01-04 15:59:41.13 spid7s 0100889F Module(sqlservr+0000889F)
2007-01-04 15:59:41.13 spid7s 010089C5 Module(sqlservr+000089C5)
2007-01-04 15:59:41.13 spid7s 010086E7 Module(sqlservr+000086E7)
2007-01-04 15:59:41.13 spid7s 010D764A Module(sqlservr+000D764A)
2007-01-04 15:59:41.13 spid7s 010D7B71 Module(sqlservr+000D7B71)
2007-01-04 15:59:41.13 spid7s 010D746E Module(sqlservr+000D746E)
2007-01-04 15:59:41.13 spid7s 010D83F0 Module(sqlservr+000D83F0)
2007-01-04 15:59:41.13 spid7s 781329AA Module(MSVCR80+000029AA)
2007-01-04 15:59:41.13 spid7s 78132A36 Module(MSVCR80+00002A36)
2007-01-04 15:59:41.13 spid7s Stack Signature for the dump is 0x2BEDE9E0
2007-01-04 15:59:41.27 spid7s External dump process return code 0x20000001.
External dump process returned no errors.
2007-01-04 15:59:41.27 spid7s Error: 17185, Severity: 16, State: 1.
2007-01-04 15:59:41.27 spid7s Unable to update password policy.
2007-01-04 15:59:41.27 spid7s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
Any clues?
Cheers
Paul
View 3 Replies
View Related
Sep 29, 2015
I have an SSRS 2012 table report with groups; each group is broken ie. one group for one page, and there are multiple groups in multiple pages.
'GroupName' column has multiple values - X,Y,Z,......
I need to group 'GroupName' with X,Y,Z,..... ie value X in page 1,value Y in page 2, value Z in page 3...
Now, I need to display another column (ABC) in this table report (outside the group column 'GroupName'); this outside column itself is another column header (not a group header) in the table (report) and it derives its name partly from the 'GroupName' values:
Example:
Value X for GroupName in page 1 will mean, in page 1, column Name of ABC column must be ABC-X Value Y for GroupName in page 2 will mean, in page 2, column Name of ABC column must be ABC-Y Value Z for GroupName in page 3 will mean, in page 3, column Name of
ABC column must be ABC-Z
ie the column name of ABC (Clm ABC) must be dynamic as per the GroupName values (X,Y,Z....)
Page1:
GroupName Clm ABC-X
X
Page2:
GroupName Clm ABC-Y
Y
Page3:
GroupName Clm ABC-Z
Z
I have been able to use First(ReportItems!GroupName.Value) in the Page Header to get GroupNames displayed in each page; I get X in page 1, Y in page 2, Z in page 3.....
However, when I use ReportItems (that refers to a group name) in the Report Body outside the group,
I get the following error:
Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope
I need to get the X, Y, Z ... in each page for the column ABC.
I have been able to use this - First(Fields!GroupName.Value); however, I get ABC-X, ABC-X, ABC-X in each of the pages for the ABC column, instead of ABC-X in page 1, ABC-Y in page 2, ABC-Z in page 3, ...
View 4 Replies
View Related
Nov 27, 2007
Hi!
I've posted a feedback with Microsoft to see if we can get them to fix the issue described below, but so far no one from Microsoft has commented to let us know what they're doing about this problem! I'm posting this here to see if maybe we can get more people to rate this feedback or chime in on what a pain it is! Please feel free to add your own comments or how you had to work around this issue and whether or not you think this is something Microsoft should be addressing NOW.
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=311679
Provide Individual Page Numbering per Group and Total Pages per Group
Currently in a Reporting Services report, you can't readily reset the page number for each group in a table, nor can you display the total number of pages per group. For example, if I'm printing invoices and each invoice is a separate group, I'd like to be able to print "Page 1 of 5" , "Page 2 of 5" etc. for the first invoice, then "Page 1 of 3" when the next invoice begins, and so on. This was easy in Crystal Reports. I realize that Crystal Reports has a two-pass process that enables that kind of pagination. However, this is REALLY important functionality that's just missing from Reporting Services and I'm hoping you'll provide it REALLY SOON! Yeah, I know there are work-arounds if you can know exactly how many rows of information there are on each page. But gosh! That's not practical, especially if you have second level groups inside the main group or text blocks in rows that can 'grow' to more than one line. I've read a couple of work-arounds, but none of them works correctly and consistently when more than one user is running the same report or when you print the report while you're looking at it on the screen. I still may need access to the overall report page number and the overall total number of pages, so don't get rid of that. It's just that if you're doing this already for the entire report, I don't see why you can't do it per group! Lots of people have been asking for this for years, and I don't understand why it hasn't been implemented.
I've read a few articles on this topic, but no one has come up with a decent work around. My theory is that Microsoft should be addressing this immediately. This is major functionality that's just plain missing from SSRS and should have been there from the start. If anyone from Microsoft can let us know what's going on with this issue or if anyone would like for me to clarify this further, feel free to let me know.
Thanks!
Karen
View 1 Replies
View Related
Nov 6, 2015
I have an SSRS report with groups that when exported to excel contains drill-in's (plus marks on left side). The issue I have is that for all the groups in the drill-in, those cells become merged. I want to keep the group drill-in but have the cells UNMERGED. I have heard this can be done with the RDL XML but I don't know what to modify to accomplish this.
View 4 Replies
View Related
Jan 10, 2014
I'd like to ask how you would get the OUTPUT below from the TABLE below:
TABLE:
id category
1 A
2 C
3 A
4 A
5 B
6 C
7 B
OUTPUT:
category count id's
A 3 1,3,4
B 2 5,7
C 2 2,6
The code would go something like:
Select category, count(*), .... as id's
from TABLE
group by category
I just need to find that .... part.
View 3 Replies
View Related
Sep 25, 2003
I have a user in SQL Server with a NT login of Mike
I changed his NT account to Mikel in User Manager
Now when I try to add Mikel, Im getting error 15401.
Do I need to delete NT login in SQL Server 'Mike' account first ?..before adding 'Mikel' ?
Can I go into the Master database and just change Mike login to Mikel ?
Thank you
View 3 Replies
View Related
Feb 28, 2014
I'm having a fight with Reporting Services at the minute when trying to compute an average at the row group level for a value summed in a column group.I have the following column groups:
Year
Month
Date
And the following row groups:
Region
Product
SubType (hidden, data at the date level is summed to Product)
At the moment I'm computing the average for SubType for each Date at the Product level (giving a decimal value), so for each day I end up with a nice average, that works. However I am unable to average that average over the whole Year for a Product. The issue being that I'm trying to combine Row Groups (Product) and Column Groups (Date/Year)
View 0 Replies
View Related
May 1, 2014
select top 15 count(*) as cnt, state from table
group by state
order by cnt desc
[code[...
Can the above three queries be combined into one and still be fast, if so how?What i am trying to go is an item count, by group, similar to ones Inbox in Outlook.
View 9 Replies
View Related
Nov 21, 2007
I have a need to show a row inside a table group to simulate a header row for the data rows inside the group. The table will not have a real header or footer. Thanks for the help.
View 1 Replies
View Related
Jan 5, 2008
I have one domoain in the forest. The domain level is set to Windows 2000 native mode and forest level is set to mixed mode. My SQL server 2005 server joined to this domain. I added a brand new domain local group and add a normal user account to this domain local group. I login to the SQL server 2005 server and make a query "SELECT * FROM sys.login_token". I cannot see my domain local group in sys.login_token. However, if I add my account to a global group, I can see it there.
Then, I setup another forest. This time, I have domain level set to Windows 2003 mode and forest level is set to Windows 2003 native mode. I do the same testing. This time, I can see my domain local group in sys.login_token.
Why does SQL server 2005 has this limitation? Is it a bug?
View 1 Replies
View Related
Feb 6, 2008
HiI am new to SQL and am having a problem. I need to fix my query to do the following...2) get a total of the number of rows returned.
DECLARE @StartDate varchar(12)DECLARE @EndDate varchar(12)DECLARE @Region varchar(20)
SET @StartDate = '01/01/2002'SET @EndDate = '12/31/2008'SET @Region = 'Central'
SELECTA.createdon,A.casetypecodename,A.subjectidname,A.title,A.accountid,A.customerid,A.customeridname,B.new_Region,B.new_RegionName
FROM dbo.FilteredIncident AINNER JOIN dbo.FilteredAccount B ON A.customerid = B.accountid
WHERE (A.createdon >=@StartDate AND A.createdon <= @EndDate)AND (B.new_RegionName = @Region)AND (A.casetypecode = 2)
View 1 Replies
View Related
Jan 29, 2007
I'm new to MSSQL 2005 and want to get a summary of a log table. I want to count all the rows for each date based on a DATETIME field called 'post_date' that holds the date and time of each record's creation.
this is the best I can come up with:
Code:
SELECT
DISTINCT(LEFT(post_date,11)) AS post_date, COUNT(DISTINCT(LEFT(post_date,11))) AS total_posts
FROM log_directory_contacts
GROUP BY post_date
The results show each date but the count column ('total_posts') returns '1' for every row even when I know their are more than 1 record on that date.
What am I doing wrong? Thanks!
View 9 Replies
View Related
May 28, 2007
Hi folks,
I have a Projects , each project have many tasks now i want to display tasks replated to each project:
for example:
Project1-------------------->task1
task2
task3
task4
Project2----------------------->task4
task5
task6
.............................................projectN.....................
how to write query for this
i have 2 tables:
Project .......>columns are projectid
Task------------->columns are projectid, taskid
|
View 4 Replies
View Related
Jun 6, 2007
I have a matrix with two row groups and one column group with about 6 items in it. I have about 2100 rows at the lowewst row group level. This report was built solely for excel export. The first row group has about 20 items and controls the visibility of the other group. When I toggle the visibility of the second row group, how can I make the the header of the first row group copy down for each row of the other row group? The first row group is the Section and the second is Mnemonic.
Example:
Now:
Code Snippet
Column Column
Section1 -
Mnemonic
Mnemonic
Mnemonic
Mnemonic
Section2 -
Mnemonic
Mnemonic
Mnemonic
Mnemonic
Should be:
Code Snippet
Column Column
Section1 -
Section1 Mnemonic
Section1 Mnemonic
Section1 Mnemonic
Section2 -
Section2 Mnemonic
Section2 Mnemonic
Section2 Mnemonic
View 2 Replies
View Related
Feb 12, 2015
I have a code like this:
SELECT Node_ID,Day,Operation, AA,BB
FROM
(SELECT
CASE
WHEN Operation LIKE 'NOTIFY' THEN SUM(Total_request) ELSE 0 END AS AA,
CASE WHEN OPERATION LIKE 'SEARCH' THEN SUM(Total_requests) ELSE 0 END AS BB,Node_ID,DAY,Operation
[code]....
So i want to make two columns by the name of operation. in the real code AA and BB are calculates with many counters. My code doesn't work, I have an error: "not a single-group group function" .....
View 1 Replies
View Related
Jul 23, 2005
Hi,I was hoping someone may be able to help me with a tricky T-SQLproblem.I need to come up with a SELECT statement that does basically thefollowing:Select RCRD_REFNO, MAX(MODIF_DTTM) as MODIF_DTTM from[StageDb].[dbo].tblPersonInfo group by RCRD_REFNOHowever, I need to select ONLY the TOP 1 of each group (i.e. only 1record for each unique RCRD_REFNO). The problem is of course that if Iadd 'top 1' after select, it only brings back 1 record full stop,rather than 1 for each group!Now, I have previously come up with a similar query that DOES do thissuccessfully, but it relies on a criteria (such as a unique identifier)-unfortunately, the nature of the table I'm using for this currentjob means that it actually doesn't have a primary key, as it'ssimply a staging area for raw data, and can even have completelyidentical records in it. I think the only way I'm going to be able todo it is to literally use the 'TOP' command somehow, but am notsure how to adapt the above to implement it...I'd be very gratefulfor any advice.Many thanks
View 6 Replies
View Related
Sep 6, 2007
Here is my Table Structure ( from Oracle database)
Team | Customer Code | Amount | Credit Limit
1 , a, 100, 1000
1 , a , 200, 1000
1 , b, 100, 100
1, b, 1000, 100
1, b, 2000, 100
2, a, 100, 2000
For the Report, I want to group the Team and Sum each customer total Amount and Show the Exceed limit amount.
Here I want to present
Team Customer Code Amount Credit Limit Exceed
1 a 300 1000 0
1 b 3100 100 3000
Team Total 3300 3000
2 a 100 2000 0
Team Total 100 0
Total 3400 3000
BUT it turn out..
Team Customer Code Amount Credit Limit Exceed
1 a 300 1000 0
1 b 3100 100 3000
Team Total 3300 2300 ( Problem here a )
2 a 100 2000 0
Team Total 100 0 ( Problem here a )
Total 3400 2400 ( Problem here b)
I Grouped the Custoer Code and Team I can preform the sum
however I can't Do the Exceed total
becoz the value should be
iif (Sum(amount)>(Creditlimt) , Sum(amount)-First(Creditlimt), 0)
but for the team total in team 1 the result is 2300 ( 3300 - customer a 's limit) not add from exceed amount
And the finial total it turns out 2400 (3400 - 1000)
I have tried use the coding to sum up the exceed
but I found that the group total is sumup first than the sum up the detail :
Team Customer Code Amount Credit Limit Exceed
1 a 300 1000 0
1 b 3100 100 3000
Team Total 3300 0
2 a 100 2000 0
Team Total 100 3000 ( The Total from Team 1 ! )
Total 3400 0 ( Problem here b)
this situration , I can't change the query statement
I can do the good result for CR report
but for reporting service 2005, I can't to the first report result
Any one can help me ??
thank you
View 9 Replies
View Related
Nov 20, 2015
need to migrate a cluster with an AG dtabases to new data center cluster with AG.
I was wondering if is possible to do mirroring on top of the AG configuration? or what other options could be to migrate a cluster that has 3 nodes and setup the ag databases to a new datacenter.
View 17 Replies
View Related
May 19, 2015
partition with single file group or multiple file group which one best.
we have some report running from partition table, few reports don't have any partition Key and after creating 400 partition with 400 file group it is slow.what is best practices to crate 400 file group or single file group.
View 9 Replies
View Related
Apr 9, 2008
How do i do a sum(IIF in a group footer. I just want to display one year total.
=SUM(IIF(Fields!Column_Text.Value="2007", Fields!Period_1.Value, 1))
This works in the details section, but gives me an error in the footer section. What should i do? PLease help, this is driving me crazy!
View 1 Replies
View Related
Dec 4, 2007
Hi all,
I have a Report and I have used Table in the report to define 5 levels of Sub Groupings: Group1, Group2, Group3, Group4, grpResourceBehavior.
The Sample data which comes is:
Group1 Group2 Group3 Group4 ResourceBehavior BgtHrs BgtAmt
A1 B1 C1 D1 NML 12 12
A1 B1 C1 D1 ODC 0 12
Now, to calculate a field "Cost", I have to use following condition. If the ResourceBehavior is NML, then Cost = BgtAmt/BgtHrs
But, if the ResourceBehavior is ODC, then COst = BgtAmt/(SUm of BgtHrs for the resourcebehavior NML)
I am not able to calculate the Sum of the BgtHrs for different ResourceBehavior. Also, I need this field calculation for each and every group as well, and this makes it all the more complicated.
Any help is appreciated.
Thanks in advance.
Swati
View 6 Replies
View Related
Mar 14, 2008
OK, hope I can explain what I need....
I have a report, which SUMS a value and groups on another field (campaign). What I need to be able to do, is take the SUMMED value from the 1st group, and subtract from this value, the value of the SUMMED value of the second group.
Example:
CAMPAIGN VALUE
CAMPAIGN A 5,000
CAMPAIGN B 1,100
I'd like to be able to subtract 1,100 from 5,000 - but can't find out how this can be done....don't forget these are grouped item's not just rows from the dataset.
I am fairly new to SSRS, so please go easy on me if this is something simple (i hope it is!)
Thanks for your help
Chris
View 6 Replies
View Related