Search Results

Search found 439 results on 18 pages for 'pivot'.

Page 8/18 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • SQL: join within same table with different 'where' clause

    - by Pmarcoen
    Ok, so the problem I'm facing is this, I have a table with 3 columns : ID, Key and Value. ID | Key | Value ================ 1 | 1 | ab 1 | 2 | cd 1 | 3 | ef 2 | 1 | gh 2 | 2 | ij 2 | 3 | kl Now I want to select the value of Keys 1 & 3 for all IDs, the return should be like this ID | 1 | 2 ================ 1 | ab | ef 2 | gh | kl So per ID 1 row containing the Values for Keys 1 & 3. I tried using 'join' but since I need to use multiple where clauses I can't figure out how to get this to work ..

    Read the article

  • Creating a [materialised]view from generic data in Oracle/Mysql

    - by Andrew White
    I have a generic datamodel with 3 tables CREATE TABLE Properties ( propertyId int(11) NOT NULL AUTO_INCREMENT, name varchar(80) NOT NULL ) CREATE TABLE Customers ( customerId int(11) NOT NULL AUTO_INCREMENT, customerName varchar(80) NOT NULL ) CREATE TABLE PropertyValues ( propertyId int(11) NOT NULL, customerId int(11) NOT NULL, value varchar(80) NOT NULL ) INSERT INTO Properties VALUES (1, 'Age'); INSERT INTO Properties VALUES (2, 'Weight'); INSERT INTO Customers VALUES (1, 'Bob'); INSERT INTO Customers VALUES (2, 'Tom'); INSERT INTO PropertyValues VALUES (1, 1, '34'); INSERT INTO PropertyValues VALUES (2, 1, '80KG'); INSERT INTO PropertyValues VALUES (1, 2, '24'); INSERT INTO PropertyValues VALUES (2, 2, '53KG'); What I would like to do is create a view that has as columns all the ROWS in Properties and has as rows the entries in Customers. The column values are populated from PropertyValues. e.g. customerId Age Weight 1 34 80KG 2 24 53KG I'm thinking I need a stored procedure to do this and perhaps a materialised view (the entries in the table "Properties" change rarely). Any tips?

    Read the article

  • How to Display result of subquery rows as one column in MySQL?

    - by SIA
    Hi I have three tables Category, Movies and RelCatMov Category-table categoryid, categoryName 1 thriller 2 supsense 3 romantic 4 action 5 sci-fi Movies-table movieid, movieName 1 Avataar 2 Titanic 3 NinjaAssassin RelCatMov-table categoryid, MovieID 1 1 2 2 3 2 4 2 5 2 Now i Want to display a the record as MovieName Categories Titanic Suspense,Romantic,Sci-fi,action How to do this. I am writing a query select MovieName,(select categoryname from category b,relcatmov c where b.categoryid=c.categoryid and c.movieid=a.movieid) as categories from movies a; Error: Subquery returns more than one row!!! How to display the result of rows in one column? Please help!!!

    Read the article

  • How to create a custom ADO Multi Demensional Catalog with no database

    - by Alan Clark
    Does anyone know of an example of how to dynamically define and build ADO MD (ActiveX Data Objects Multidimensional) catalogs and cube definitions with a set of data other than a database? Background: we have a huge amount of data in our application that we export to a database and then query using the usual SQL joins, groups, sums etc to produce reports. The data in the application is originally in objects and arrays. The problem is the amount of data is so large the export can take 2 hours. So I am trying to figure out a good way of querying the objects in memory, either by a custom OLAP algorithm or library, or ADO MD. But I haven't been able to find an example of using ADO MD without a database behind it. We are using Delphi 2010 so would use ADO ActiveX but I imagine the ADO.NET MD is similar. I realize that if the application data was already stored in a database the problem would solve itself. Also if Delphi had LINQ capability I could query the objects and arrays that way.

    Read the article

  • Reading records from Excel PivotCache

    - by hcpremium
    I have an Excel workbook which contains a PivotCache I would like to use as a data source. var file = @"Foo.xls"; var excel = new Excel.Application(); var workbook = excel.Workbooks.Open(file); Excel.PivotCache cache = null; foreach (Excel.PivotCache pivotCache in workbook.PivotCaches()) { if (...) { cache = pivotCache; } } var records = cache.Recordset; The last command throws an exception (Exception from HRESULT: 0x800A03EC). How can I access the PivotCache? I tried it thru Ole DB first, but no success...

    Read the article

  • Excel - Best Way to Connect With Access Data

    - by gamerzfuse
    Hello there, Here is the situation we have: a) I have an Access database / application that records a significant amount of data. Significant fields would be hours, # of sales, # of unreturned calls, etc b) I have an Excel document that connects to the Access database and pulls data in to visualize it As it stands now, the Excel file has a Refresh button that loads new data. The data is loaded into a large PivotTable. The main 'visual form' then uses VLOOKUP to get the results from the form, based on the related hours. This operation is slow (~10 seconds) and seems to be redundant and inefficient. Is there a better way to do this? I am willing to go just about any route - just need directions. Thanks in advance! Update: I have confirmed (due to helpful comments/responses) that the problem is with the data loading itself. removing all the VLOOKUPs only took a second or two out of the load time. So, the questions stands as how I can rapidly and reliably get the data without so much time involvement (it loads around 3000 records into the PivotTables).

    Read the article

  • SQL Aggregate all Purchases for a certain product with same rebatecode

    - by debuggerlikeanother
    Hi SO, i would like to aggregate all purchases for a certain product that used the same rebatecode (using SQL Server 2005) Assume we have the following table: ID ProductID Product RebateCode Amount 1 123 7HM ABC 1 2 123 7HM XYZ 2 3 124 7HM ABC 10 4 124 7HM XYZ 20 5 125 2EB LOI 4 6 126 2EB LOI 40 CREATE TABLE #ProductSales(ID SMALLINT, ProductID int, Product varchar(6), RebateCode varchar(4), Amount int) GO INSERT INTO #ProductSales select 1, 123, '7HM', 'A', 1 union all select 2, 123, '7HM', 'B', 2 union all select 3, 124, '7HM', 'A', 10 union all select 4, 124, '7HM', 'B', 20 union all select 5, 125, '7HM', 'A', 100 union all select 6, 125, '7HM', 'B', 200 union all select 7, 125, '7HM', 'C', 3 union all select 8, 126, '2EA', 'E', 4 union all select 8, 127, '2EA', 'E', 40 union all select 9, 128, '2EB', 'F', 5 union all select 9, 129, '2EB', 'F', 50 union all select 10, 130, '2EB', 'F', 500 GO SELECT * FROM #ProductSales GO /* And i would like to have the following result Product nrOfProducts CombinationRebateCode SumAmount ABC LOI XYZ 7HM 2 ABC, XYZ 33 11 0 22 2EB 2 LOI 44 0 44 0 .. */ CREATE TABLE #ProductRebateCode(Product varchar(6), nrOfProducts int, sumAmountRebateCombo int, rebateCodeCombination varchar(80), A int, B int, C int, E int, F int) Go INSERT INTO #ProductRebateCode select '7HM', 2, 33, 'A, B', 2, 2, 0, 0, 0 union all select '7HM', 1, 303, 'A, B, C', 1, 1, 1, 0, 0 union all select '2EA', 2, 44, 'E', 0, 0, 0, 2, 0 union all select '2EB', 3, 555, 'E', 0, 0, 0, 0, 2 Select * from #ProductRebateCode -- Drop Table #ProductSales IF EXISTS ( SELECT * FROM tempdb.dbo.sysobjects WHERE name LIKE '#ProductSales%') DROP TABLE #ProductSales -- Drop Table #ProductRebateCode IF EXISTS ( SELECT * FROM tempdb.dbo.sysobjects WHERE name LIKE '#ProductRebateCode%') DROP TABLE #ProductRebateCode I would like to have the result like in the example (see second select (#ProductRebateCode). I tried to achieve it with the crosstab from this post: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6216&whichpage=6. exec CrossTab2b @SQL = 'SELECT [ProductID], Product, RebateCode, Amount FROM #ProductSales' ,@PivotCol = 'RebateCode' ,@Summaries = 'Sum(Amount ELSE 0)[_Sum], Count([ProductID])[_nrOfProducts]' /* SUM(Amount ELSE 0)[Amount], COUNT(Amount)[Qty] */ ,@GroupBy = 'RebateCode, Product' ,@OtherFields = 'Product' I believe that this could work, but i am unable to solve it. Do you believe that it is possible to achieve what i am trying without MDX or the other fancy ?DX-Stuff? Best regards And Thanks a lot debugger the other

    Read the article

  • How to convert rows returned by a query into columns in oracle?

    - by Piyush Lohana
    I have to display the results of the below query as columns. select to_char(sysdate + 1 - rownum,'MON-YYYY') as d from all_objects where trunc(sysdate + 1 - rownum,'MM') = trunc(to_date(:from_date,'MON-YYYY'),'MM') minus select to_char(sysdate + 1 - rownum,'MON-YYYY') as d from all_objects where trunc(sysdate + 1 - rownum,'MM') trunc(to_date(':to_date','MON-YYYY'),'MM') Please help me in figuring that out.

    Read the article

  • How can I "merge" or "flatten" results from a query which returns multiple rows into a single result

    - by dsm
    I have a simple query over a table, which returns results like the following: id id_type id_ref 2702 5 31 2702 16 14 2702 17 3 2702 40 1 2702 26 4 And I would like to merge the results into a single row, for instance: id concatenation 2702 5,16,17,40,26:31,14,3,1,4 Is there any way to do this within a trigger? NB: I know I can use a cursor, but I would really prefer not to unless there is no better way.

    Read the article

  • SQL Server pivots? some way to set column names to values within a row

    - by ccsimpson3
    I am building a system of multiple trackers that are going to use a lot of the same columns so there is a table for the trackers, the tracker columns, then a cross reference for which columns go with which tracker, when a user inserts a tracker row the different column values are stored in multiple rows that share the same record id and store both the value and the name of the particular column. I need to find a way to dynamically change the column name of the value to be the column name that is stored in the same row. i.e. id | value | name ------------------ 23 | red | color 23 | fast | speed needs to look like this. id | color | speed ------------------ 23 | red | fast Any help is greatly appreciated, thank you.

    Read the article

  • In Excel 2010, how can I show a count of occurrences on a specific date within multiple time ranges?

    - by Justin
    Here's what I'm trying to do. I have three columns of data. ID, Date(MM/DD/YY), Time(00:00). I need to create a chart or table that shows the number of occurrences on, say, 12/10/2010 between 00:00 and 00:59, 1:00 and 1:59, etc, for each hour of the day. I can do countif and get results for the date, but I cannot figure out how to show a summary of the count of occurrences per hour for the 24 hour period. I have months of data and many times each day. Example of data set is below. Any help is greatly ID Date Time 221 12/10/2010 00:01 223 12/10/2010 00:45 227 12/10/2010 01:13 334 12/11/2010 14:45 I would like the results to read: Date Time Count 12/10/2010 00:00AM - 00:59AM 2 12/10/2010 01:00AM - 01:59AM 1 12/10/2010 02:00AM - 02:59AM 0 ......(continues for every hour of the day) 12/11/2010 00:00AM - 00:59AM 0 ......... 12/11/2010 14:00PM - 14:59PM 1 And so on. Sorry for the length but I wanted to be clear. EDIT Here is a sample spreadsheet. Very little data, but I couldn't figure out a better way without having a huge file. Tested in notepad for formatting and worked ok on import as csv. PID,Date,Time 2888759,12/10/2010,0:10 2888760,12/10/2010,0:10 2888761,12/10/2010,0:10 2888762,12/10/2010,0:11 2889078,12/10/2010,15:45 2889079,12/10/2010,15:57 2889080,12/10/2010,15:57 2889081,12/10/2010,15:58 2889082,12/10/2010,16:10 2889083,12/10/2010,16:11 2889084,12/10/2010,16:11 2889085,12/10/2010,16:12 2889086,12/10/2010,16:12 2889087,12/10/2010,16:12 2889088,12/10/2010,16:13 2891529,12/14/2010,16:21

    Read the article

  • join select from multiple row values?

    - by user1869132
    Two tables 1) product -------------------- id | Name | price 1 | p1 | 10 2 | p2 | 20 3 | p3 | 30 2) product_attributes: --------------------------------------------------- id | product_id | attribute_name | attribute_value --------------------------------------------------- 1 | 1 | size | 10 2 | 1 | colour | red 3 | 2 | size | 20 I need to join these two tables. In the where clause I need to match both the two rows attribute values. Is it possible to get the result based on two rows value. Here if size=10 and colour=red. Output should be 1 | p1 | 10 It could be greatly helpful to get a query for this.

    Read the article

  • Side-by-side comparison of data by month in SQL

    - by ScottR
    I have table similar to the following: Year | Product | Value 2006 A 10 2006 B 20 2006 C 30 2007 A 40 2007 B 50 2007 C 60 I would like a query that would return the following comparison Product | 2006 Value | 2007 Value A 10 40 B 20 50 C 30 60 What are the options to do so? Can it be done without joins? I'm working with DB2, but answers in all SQL types would be helpful.

    Read the article

  • Using Recursive SQL and XML trick to PIVOT(OK, concat) a "Document Folder Structure Relationship" table, works like MySQL GROUP_CONCAT

    - by Kevin Shyr
    I'm in the process of building out a Data Warehouse and encountered this issue along the way.In the environment, there is a table that stores all the folders with the individual level.  For example, if a document is created here:{App Path}\Level 1\Level 2\Level 3\{document}, then the DocumentFolder table would look like this:IDID_ParentFolderName1NULLLevel 121Level 232Level 3To my understanding, the table was built so that:Each proposal can have multiple documents stored at various locationsDifferent users working on the proposal will have different access level to the folder; if one user is assigned access to a folder level, she/he can see all the sub folders and their content.Now we understand from an application point of view why this table was built this way.  But you can quickly see the pain this causes the report writer to show a document link on the report.  I wasn't surprised to find the report query had 5 self outer joins, which is at the mercy of nobody creating a document that is buried 6 levels deep, and not to mention the degradation in performance.With the help of 2 posts (at the end of this post), I was able to come up with this solution:Use recursive SQL to build out the folder pathUse SQL XML trick to concat the strings.Code (a reminder, I built this code in a stored procedure.  If you copy the syntax into a simple query window and execute, you'll get an incorrect syntax error) Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} -- Get all folders and group them by the original DocumentFolderID in PTSDocument table;WITH DocFoldersByDocFolderID(PTSDocumentFolderID_Original, PTSDocumentFolderID_Parent, sDocumentFolder, nLevel)AS (-- first member      SELECT 'PTSDocumentFolderID_Original' = d1.PTSDocumentFolderID            , PTSDocumentFolderID_Parent            , 'sDocumentFolder' = sName            , 'nLevel' = CONVERT(INT, 1000000)      FROM (SELECT DISTINCT PTSDocumentFolderID                  FROM dbo.PTSDocument_DY WITH(READPAST)            ) AS d1            INNER JOIN dbo.PTSDocumentFolder_DY AS df1 WITH(READPAST)                  ON d1.PTSDocumentFolderID = df1.PTSDocumentFolderID      UNION ALL      -- recursive      SELECT ddf1.PTSDocumentFolderID_Original            , df1.PTSDocumentFolderID_Parent            , 'sDocumentFolder' = df1.sName            , 'nLevel' = ddf1.nLevel - 1      FROM dbo.PTSDocumentFolder_DY AS df1 WITH(READPAST)            INNER JOIN DocFoldersByDocFolderID AS ddf1                  ON df1.PTSDocumentFolderID = ddf1.PTSDocumentFolderID_Parent)-- Flatten out folder path, DocFolderSingleByDocFolderID(PTSDocumentFolderID_Original, sDocumentFolder)AS (SELECT dfbdf.PTSDocumentFolderID_Original            , 'sDocumentFolder' = STUFF((SELECT '\' + sDocumentFolder                                         FROM DocFoldersByDocFolderID                                         WHERE (PTSDocumentFolderID_Original = dfbdf.PTSDocumentFolderID_Original)                                         ORDER BY PTSDocumentFolderID_Original, nLevel                                         FOR XML PATH ('')),1,1,'')      FROM DocFoldersByDocFolderID AS dfbdf      GROUP BY dfbdf.PTSDocumentFolderID_Original) And voila, I use the second CTE to join back to my original query (which is now a CTE for Source as we can now use MERGE to do INSERT and UPDATE at the same time).Each part of this solution would not solve the problem by itself because:If I don't use recursion, I cannot build out the path properly.  If I use the XML trick only, then I don't have the originating folder ID info that I need to link to the document.If I don't use the XML trick, then I don't have one row per document to show in the report.I could conceivably do this in the report function, but I'd rather not deal with the beginning or ending backslash and how to attach the document name.PIVOT doesn't do strings and UNPIVOT runs into the same problem as the above.I'm excited that each version of SQL server provides us new tools to solve old problems and/or enables us to solve problems in a more elegant wayThe 2 posts that helped me along:Recursive Queries Using Common Table ExpressionHow to use GROUP BY to concatenate strings in SQL server?

    Read the article

  • Why does Application_Deactivated not get called on a pivot page?

    - by willmel
    For my Windows Phone 7 app, I have a main panorama page which opens up into a pivot control. The main panorama page correctly calls Activated/Deactivated, and restores correctly. But after visiting the pivot page, pressing the Windows key doesn't call Deactivated. When the app is relaunched with the back button, it goes right to how the page looked before tombstoning, but Activated is not called, and the page is not usable, and the back key doesn't work. Has anyone else experienced this problem before?

    Read the article

  • PROPSHEETHEADER and PSH_PIVOT to get the horizontal pivot scroll?

    - by Johann Gerell
    Windows Mobile 6.5.3 has a "touch friendlier" pivot at the top of the screen instead of tabs at the bottom. In the docs for PROPSHEETHEADER, the dwFlag value PSH_PIVOT is documented: PSH_PIVOT Applies to Windows Mobile 6.5.3 Replaces dialog box tabs with a simple pivot (horizontal spinner). It's supposed to bed defined in prsht.h, but it's not. My 6.5.3 and 6 headers differ only in this: #define PSM_GETPIVOTCONTROL (WM_USER + 119) #define PropSheet_GetPivotControl(hDlg) \ (HWND)SNDMSG(hDlg, PSM_GETPIVOTCONTROL, 0, 0) which is in the 6.5.3 prsht.h, but not in the 6 one. What's the value of PSH_PIVOT? Did they forget to include it?

    Read the article

  • Laravel4: Checking many-to-many relationship attribute even when it does not exist

    - by Simo A.
    This is my first time with Laravel and also Stackoverflow... I am developing a simple course management system. The main objects are User and Course, with a many-to-many relationship between them. The pivot table has an additional attribute, participant_role, which defines whether the user is a student or an instructor within that particular course. class Course extends Eloquent { public function users() { return $this->belongsToMany('User')->withPivot('participant_role')->withTimestamps(); } } However, there is an additional role, system admin, which can be defined on the User object. And this brings me mucho headache. In my blade view I have the following: @if ($course->pivot->participant_role == 'instructor') { // do something here... } This works fine when the user has been assigned to that particular $course and there is an entry for this user-course combination in the pivot table. However, the problem is the system administrator, who also should be able to access course details. The if-clause above gives Trying to get property of non-object error, apparently because there is no entry in the pivot table for system administrator (as the role is defined within the User object). I could probably solve the problem by using some off-the-shelf bundle for handling role-based permissions. Or I could (but don't want to) do something like this with two internal if-clauses: if (!empty($course->pivot)) { if ($course->pivot->participant_role == 'instructor') { // do something... } } Other options (suggested in partially similar entries in Stackoverflow) would include 1) reading all the pivot table entries to an array, and use in_array to check if a role exists, or even 2) SQL left join to do this on database level. However, ultimately I am looking for a compact one-line solution? Can I do anything similar to this, which unfortunately does not seem to work? if (! empty ($course->pivot->participant_role == 'instructor') ) { // do something... } The shorter the answer, the better :-). Thanks a lot!

    Read the article

  • Is it possible to use the WP7 Panorama or Pivot in SL4?

    - by Detroitpro
    I'm making pretty heavy use of the Panorama and Pivot controls in my WP7 applications. Is it possible to use these same controls in a standard Silverlight (4) application? http://phone.codeplex.com/ I added the dll's, was able to compile and create the controls in my views. However; I was not able to "Scroll". I thought they used the "LeftMouseDown" event handlers but I guess I'm wrong.

    Read the article

  • t-sql most efficient row to column? for xml path, pivot

    - by ajberry
    create table _orders ( OrderId int identity(1,1) primary key nonclustered ,CustomerId int ) create table _details ( DetailId int identity(1,1) primary key nonclustered ,OrderId int ,ProductId int ) insert into _orders (CustomerId) select 1 union select 2 union select 3 insert into _details (OrderId,ProductId) select 1,100 union select 1,158 union select 1,234 union select 2,125 union select 3,105 union select 3,101 union select 3,212 union select 3,250 -- select orderid ,REPLACE(( SELECT ' ' + CAST(ProductId as varchar) FROM _details d WHERE d.OrderId = o.OrderId ORDER BY d.OrderId,d.DetailId FOR XML PATH('') ),'&#x20;','') as Products from _orders o I am looking for the most performant way to turn rows into columns. I have a requirement to output the contents of the db (not actual schema above, but concept is similar) in both fixed width and delimited formats. The above FOR XML PATH query gives me the result I want, but when dealing with anything other than small amounts of data, can take awhile. I've looked at pivot but most of the examples I have found are aggregating information. I just to combine the child rows and tack them onto the parent. For example, for an order it would need to output: OrderId,Product1,Product2,Product3,etc Thoughts or suggestions? I am using SQL Server 2k5.

    Read the article

  • t-sql most efficient row to column? crosstab for xml path, pivot

    - by ajberry
    I am looking for the most performant way to turn rows into columns. I have a requirement to output the contents of the db (not actual schema below, but concept is similar) in both fixed width and delimited formats. The below FOR XML PATH query gives me the result I want, but when dealing with anything other than small amounts of data, can take awhile. select orderid ,REPLACE(( SELECT ' ' + CAST(ProductId as varchar) FROM _details d WHERE d.OrderId = o.OrderId ORDER BY d.OrderId,d.DetailId FOR XML PATH('') ),'&#x20;','') as Products from _orders o I've looked at pivot but most of the examples I have found are aggregating information. I just want to combine the child rows and tack them onto the parent. I should also point out I don't need to deal with the column names either since the output of the child rows will either be a fixed width string or a delimited string. For example, given the following tables: OrderId CustomerId ----------- ----------- 1 1 2 2 3 3 DetailId OrderId ProductId ----------- ----------- ----------- 1 1 100 2 1 158 3 1 234 4 2 125 5 3 101 6 3 105 7 3 212 8 3 250 for an order I need to output: orderid Products ----------- ----------------------- 1 100 158 234 2 125 3 101 105 212 250 or orderid Products ----------- ----------------------- 1 100|158|234 2 125 3 101|105|212|250 Thoughts or suggestions? I am using SQL Server 2k5. Example Setup: create table _orders ( OrderId int identity(1,1) primary key nonclustered ,CustomerId int ) create table _details ( DetailId int identity(1,1) primary key nonclustered ,OrderId int ,ProductId int ) insert into _orders (CustomerId) select 1 union select 2 union select 3 insert into _details (OrderId,ProductId) select 1,100 union select 1,158 union select 1,234 union select 2,125 union select 3,105 union select 3,101 union select 3,212 union select 3,250 using FOR XML PATH: select orderid ,REPLACE(( SELECT ' ' + CAST(ProductId as varchar) FROM _details d WHERE d.OrderId = o.OrderId ORDER BY d.OrderId,d.DetailId FOR XML PATH('') ),'&#x20;','') as Products from _orders o which outputs what I want, however is very slow for large amounts of data. One of the child tables is over 2 million rows, pushing the processing time out to ~ 4 hours. orderid Products ----------- ----------------------- 1 100 158 234 2 125 3 101 105 212 250

    Read the article

  • Anyone using a web service as a data source in Excel 2007?

    - by Scott
    Can I use a web service as a data soruce for Excel pivot tables? Currently, the soure data for the pivot table is being exported from the DB to a CSV file. Then the CSV file is loaded into a worksheet in the workbook. From there, a pivot table is created in the same workbook. We are looking to streamline this process. The SQL db and pivot tables are the constants. The pivot tables are generated dynamically from a public-facing website. This is not an internal app so the preference is to not connect directly to the DB.

    Read the article

  • Kohana 3, problem with m2m data adding

    - by Marek
    Hello I posted this on official forum but with no result. I am getting :Undefined index: enrollment error when trying to save data. My pivot model: class Model_Enrollment extends ORM { protected $_belongs_to = array('page' => array(), 'menugroup' => array()); } Model_Page protected $_has_many = array('templates' => array(), 'menugroups' => array('through' => 'enrollment')); Model_Menugroup protected $_has_many = array('menuitems' => array(), 'pages' => array('through' => 'enrollment')); //Overriden save() method in Model_Menugroup: public function save() { if (empty($this->created)) { $this->created = time(); } parent::save(); $this->reload(); if (! $this->is_global) { if (! empty($this->groupOwnerPagesId) { $page = ORM::factory('page'); foreach($this->groupOwnerPagesId as $id) { $this->add('enrollment', $page->find($id)); } } } } I did: I corrected table names in pivot model by changing them to singular I even now using the same name for pivot table / model = enrollment. The same as in tutorial. Just in case So the pivot table has name 'enrollment' and has 2 columns: page_id , menugroup_id I tried to add pk in pivot table, but it changed nothing I tried to add/remove db relation between pages/menugroups and pivot table (InnoDB) but with no luck I tried save all data in controller, but with the same bad result:( I am still getting the same error: Undefined index: enrollment in ORM line: $columns = array($this-_has_many[$alias]['foreign_key'], $this-_has_many[$alias]['far_key']); Could somebody tell me, what can be else wrong? I have no other ideas:( Kind regards

    Read the article

  • In SQL, how can I count the number of values in a column and then pivot it so the column becomes the

    - by Josh Yeager
    I have a survey database with one column for each question and one row for each person who responds. Each question is answered with a value from 1 to 3. Id Quality? Speed? -- ------- ----- 1 3 1 2 2 1 3 2 3 4 3 2 Now, I need to display the results as one row per question, with a column for each response number, and the value in each column being the number of responses that used that answer. Finally, I need to calculate the total score, which is the number of 1's plus two times the number of 2's plus three times the number of threes. Question 1 2 3 Total -------- -- -- -- ----- Quality? 0 2 2 10 Speed? 2 1 1 7 Is there a way to do this in set-based SQL? I know how to do it using loops in C# or cursors in SQL, but I'm trying to make it work in a reporting tool that doesn't support cursors.

    Read the article

  • pivots using pyExcelerator/xlrd

    - by Raj N
    How can I go about creating a sheet with a pivot table using python libs like pyExcelerator / xlrd? I need to generate a daily report that has a pivot table to summarize data on other sheets. One option would be to have a blank template that I copy and populate with the data. In this case, is there a way to refresh the pivot from code? Any other suggestions?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >