sql

  • Avoid sql code redundancy 2019-01-12

    Need help on avoiding the SQL code redundancy below is the SQL statement in which column dept10 and dept20 have same code but with little bit of difference. Can someone help on how to avoid it, since due to that statement is taking too long to run. N

    Tags: sql, oracle, oracle10g
  • Dynamic Query Generation is not working with SQL 2019-01-06

    I am trying to execute following SQL statement : USE[Northwind] declare @MainQuery varchar(255), @WhereClause varchar(255) Select @WhereClause = 'where CustomerId =ALFKI' Select @MainQuery ='Select * from Customers '[email protected] execute(@MainQuery)

    Tags: sql, sql server
  • How to performance tune this query? 2019-01-04

    Need help in performance tuning the query. The execution plan shows the scan count is too high on SResourceHierarchy and grouprelationship tables around in millions. I created covering indexes on sresource and matrix goal that reduced the time majorl

    Tags: database, sql, sql server
  • Combine date ranges in a table 2019-01-04

    This question already has an answer here: How do I group on continuous ranges 5 answers I have the following table id price startdate enddate product 1 112 12/05/2015 12/05/2015 A 2 112 13/05/2015 13/05/2015 A 3 112 14/05/2015 14/05/2015 A 4 112 15/0

    Tags: sql, sql server
  • How to return an value/null no matter the column value is exist or not 2018-12-27

    TABLES <<USER>> id name ------------ 1 alex 2 gary 3 peter 4 mary <<ITEMS>> id index items ----------------- 1 1 iphone 1 2 apple 2 1 nokia SQL SELECT u.id, u.name, i.items FROM USER u, ITEMS i WHERE u.id = item.id(+) AND (item.ind

    Tags: sql, oracle
  • Displaying Arabic script while converting from Access database 2018-12-21

    I have converted my database from Microsoft Access to SQL Server 2008 database. All the columns converted successfully. But the Arabic scripts in one column didn't display properly in SQL Server. It display Arabic script as Îáíå ßíæÝÊ ãÑÈÚå. Please h

    Tags: sql, sql server, ms access
  • How to include last updated row in RoR 2018-12-13

    So I have two models, Category and Topic and any category can have many topics. The question is, how do I query for all categories and include each category's last updated topic? If I do something like this class Category < ActiveRecord::Base has_man

    Tags: sql, ruby on rails, postgresql
  • Data integrity exception with hibernate 2018-12-13

    I created 300 records from backend with primary keys, So now when these primary key's are generating through hibernate then data integrity exception shows. Hilo algorithm is using to generate key's org.springframework.dao.DataIntegrityViolationExcept

    Tags: sql, postgresql, hibernate
  • To select range of values between two columns 2018-11-24

    I have a table which has 4 columns and i want to get a value between two range of values in column .I tried but it returns null.Pls help me to over come the issue. GradeID | FAMin|FAMax| FAGrade| 1 | 37 | 40 | A1| SELECT * FROM GradeSystems WHERE FAM

    Tags: sql, sql server
  • Biggest/Longest records in varchar table 2018-11-10

    We recently noticed that in one of our biggest tables some of the rows are a few times bigger than others. By "bigger" I mean longer and taking more storage space. How to display top 1000 biggest rows in the table? Almost all columns are varchar

    Tags: sql, sql server, varchar, maxlength
  • Stored Procedure runs over one dataset, but hangs over the other 2018-11-08

    I have a stored procedure which pulls a large SQL blob from a table. That SQL blob returns tens of thousands of records and then the SP performs certain actions on those records (inserts into different tables) . Essentially, the blob looks something

    Tags: sql, sql server 2008
  • 1 Working Day Back In SQL DB2 2018-10-30

    I need to select data from database with a date that is one day back into the past but on working day. Is there a specific function for that ( Excel has got formula =Workday)? I am downloading data from DB2 to excel with VBA instructions. Here is the

    Tags: sql, db2, vba
  • Sql: How to combine multiple rows into a string as an expression within an update 2018-10-29

    In sql (MS sql server specifically) is it possible to combine multiple rows into a single string as an expression which is itself part of an update that is being applied to multiple rows. I have come across the approaches of using COALESCE or FOR XML

    Tags: sql, sql server
  • Getting 0 rows returned on query 2018-10-28

    so let me start will the basic table layout for all tables involved: #zip_code_time_zone +----+----------+-----------+ | id | zip_code | time_zone | +----+----------+-----------+ | 1 | 00544 | -1 | | 2 | 00601 | -3 | | 3 | 00602 | 0 | | 4 | 00603 | -

    Tags: sql, sql server
  • how to insert records from one table to another selecting only the common columns 2018-10-16

    i want to insert records from one table to another with common columns desc fp_mast null? type emp_id not null varchar2(4) emp_nm not null varchar2(35) typ not null varchar2(1) flag not null varchar2(1) st_dt not null DATE end_dt DATE wk_dt not null

    Tags: sql, oracle, select
  • Spark SQL: ORDER BY count DESC fails? 2018-10-15

    There is a table with two columns books and readers of these books, where books and readers are book and reader IDs, respectively. When trying to order readers by number of books they read, I get AbstractSparkSQLParser exception: import org.apache.sp

    Tags: sql, apache spark
  • SQL multiple queries response to variables 2018-10-13

    I want to make multiple queries in single connection I do this like FileName = "d:\database.mdb" strCnn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & FileName strSQL = "SELECT ID FROM [Users];SELECT DISTINCT ID FROM [Use

    Tags: sql, ms access, ole, ado
  • SQL max by 2 column, or first and last aggregate function 2018-09-16

    How to get max by colum1 1 then by colum 2 in sql? and is there aggregate function like first or last? I tried 2 ways: 1-it's get me max date but the max price is not associated with max date: SELECT doc_kits_t.DateOper, kits_t.DocId, kits_t.GoodId,M

    Tags: sql, sql server
  • Strange behaviour of two simple SQL Statement (Error) and one is crashing 2018-09-11

    I have a database table with 50.000 customer data records. When I run this query: SELECT * FROM customer --> The result is, that I get only 22.000 data records. When I run this query: SELECT * FROM customer WHERE customer_id < 50.001 --> The resu

    Tags: sql, sql server, select, sql server 2008 r2
  • Update Column based on Bulk insert from CSV SQL 2018-09-08

    I am trying to update a table based on the CSV file. I have got list of Id's and trim number in CSV and I need to update the Trim number based on the specific id's in the SQL table. So far the script I have written -- Create a temporary table for the

    Tags: sql, sql server, csv

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.151 (s). 7 q(s)