Structured Query Language (SQL). For questions about the language, not Microsoft SQL Server (tag sql-server).

learn more… | top users | synonyms (1)

0
votes
0answers
3 views

Different where clause based on SSRS parameter

I have an SSRS report where a parameter can take 3 values. The select query is the same in all cases but the where clause needs to check different date fields based on the parameter value. Is this ...
3
votes
4answers
59 views

Question about 'mysql error 1064'

ALTER TABLE sample62 CHANGE newcol c; This code makes me mad. I just followed the book I had. Program said You have an error in your SQL syntax; check the manual that corresponds to your ...
0
votes
0answers
10 views

Cannot create user using administrator credentials in Oracle

I am trying to get some hands-on experience with ORACLE and I installed Oracle Database 11g Express Edition on my PC at home. I logged into the 'Application Express' by entering TEST in the Workspace ...
0
votes
1answer
33 views

How to select all rows from column including two specific numbers within a set of digits, but not in beginning or end?

I'm attempting to retrieve all rows that include two specific characters within a set of characters corresponding to the attributable column of data. However, the specified characters can't be ...
0
votes
1answer
33 views

How to optimize database for specific queries?

Hello I have built this queries thanks answers to my questions: How to get data from three different tables and How to show rows with 0 without any records in database But now I have performance ...
-1
votes
0answers
14 views

SQL Stored Procedure how to split column [on hold]

ALTER PROCEDURE [dbo].[MBResult] -- Add the parameters for the stored procedure here AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. ...
-4
votes
1answer
26 views

sql INSERT QUERY [on hold]

i want to write a query for this. I want to select funds from table1 and insert them into table2 in their respective hrchy no . as shown in pic
-1
votes
0answers
18 views

Writing SQL query for scenario [on hold]

I am trying to develope a shopping application. I need to write a query for the following table structures : enter image description here GRPMT : This contains the master group of Items(like ...
0
votes
0answers
23 views

Transaction Identifier - possible with MySQL?

I have quite complex code, which at the beginning starts transaction. After that several user queries are performed (more or less without my control) and at the end the transaction is committed if ...
1
vote
0answers
26 views

Change login name for all objects on server

Example, I have a create a windows login DOMAIN\GROUP01, and mapped that login to a database DATABASE01 with lets say DB_OWNER permissions I want to change the login name, I went into Active ...
1
vote
1answer
70 views

SQL Query on partitioning does not run [duplicate]

When I run the following SQL command select payee_id, start_dt, row_number() over(partition by payee_id order by start_dt) as rn from xxx where rn = 1 I got an error : error Invalid ...
2
votes
2answers
84 views

Ordering groups/partition windows by other column values

I have a sample from a database I'm using in SQL server 2014 you can use here http://sqlfiddle.com/#!6/0d98e/1 It looks like this ...
-2
votes
0answers
18 views

My login page is returning Unknown column 'sitlanic' in 'where clause'

My login page is returning: Unknown column 'sitlanic' in 'where clause' $uname = $_POST['name']; $pass=$_POST['b']; $sql="select*from names where username=$uname and password=$pass"; ...
0
votes
0answers
39 views

create table in a different schema

I am trying to create a table on a different schema without using "create any table" privilege. I have an application user/schema. TABLESPACE_NAME USEDMB MAXMB ...
0
votes
1answer
30 views

MySQL - Many to Many Join. Left Join already Present

I am building a Attendance System for a Client and have become a tad stuck with JOIN's. I already have a left JOIN running, and want to add a JOIN on a many-to-many relationship but can't get my head ...
1
vote
2answers
54 views

SQL Server Concurrency Issue [on hold]

We have a SQL server concurrency issue we are facing and would like some ideas on how to solve it. There are several procedures we have written the contain INSERT/UPDATE statements on tables in a Set ...
1
vote
1answer
48 views

understanding ORA-01792 maximum number of columns in a table or view is 1000

We've recently migrated a server from Oracle 11 to Oracle 12c and ran into a few annoying issues. One of them is that a few a reports give the following error: ORA-01792: maximum number of columns ...
2
votes
0answers
34 views

How to Replicate data between a hosted database and a local database

I have a Cloud hosted Database, maintained by a different company. Here is my scenario: Cloud Hosted Database SQL2012 - Need to connect through a VPN. We setup a local Server with with Dual NIC ...
0
votes
2answers
37 views

Query that finds the oldest driver

Given two tables: driver=(d_id,name,gender,birthday,address,country) event_list=(o_id,d_id,odate,oplace) The event list table represent the driving violations of the driver , o_id is the violation ...
3
votes
1answer
77 views

How to show rows with 0 without any records in database

I have a lot of record in my database and for data analysis, I need to show count of records for each day including days when I do not have any record, so result is 0. For example I have these ...
0
votes
1answer
26 views

How to get average of views before clicking on advertisement?

I've got two tables containing information about viewing and clicking on advertisement by each user: Clicks: userID Action Time 123 c 2016-01-08 01:57:00 123 c 2016-01-11 ...
0
votes
0answers
11 views

Trouble With Basic Query Searching [migrated]

Not sure if the this is the right place to ask but i have a question with beginner sql. I have the table dept and emp which include: SQL> desc dept; Name ...
0
votes
1answer
56 views

Oracle SQL: Outer Join Not Working As Expected

I am joining two tables, T_ADMSTU_PROG_ENROLL (renamed prog_enroll) and T_ADMGRAD_STUDENT (renamed grad). I would expect the result to have the following columns: TERM_CODE, STU_INST_UID, MAJOR_DESC, ...
0
votes
0answers
24 views

transpose rows into colunms based on date grouping

I have a table with rows as such Number Date Number2 16 2016-02-03 34 9 2016-02-03 34 30 2016-02-03 34 7 2016-02-03 34 47 2016-02-03 34 1 2016-02-03 34 ...
3
votes
2answers
61 views

Creating calculated column

I want to create a rating weight and I need do calculate AVG, then find COUNT and multiply both to get weight. I have something like that: SELECT post_id, COUNT(CASE WHEN vote > 0 THEN vote ELSE ...
1
vote
1answer
27 views

Show only duplicate values

How to select rows with duplicate values (non-distinct rows) and summarize with a count of the number of duplicate values in order of the most frequent duplicates? Given a table of: person_ name_ ...
0
votes
0answers
25 views

Join query not working [on hold]

select distinct concat(ed.first_name,'',ed.middile_name,'',ed.last_name) empname, emp_fkey, au.* from emp_details ed INNER join emp_ctc_upload au on (ed.emp_pkey = ...
-1
votes
0answers
24 views

windows 10 home, 64 bit… trouble running a certain software requiring 2k8r2, would like to run these ideas by you [on hold]

I need to run a programming software that requires 2008r2, I cant finish installing the software because it wants to install its own instance of 2k8r2. Can I install sql first then run the software? ...
0
votes
1answer
20 views

MS Access Run Multiple Queries

I have eight 'append' queries in MS Access 2010 that I want to be able to run. Each query also needs to take one parameter (a project number). I want to run all eight, entering the parameter only ...
1
vote
1answer
30 views

How to check value when i have a list of elements separated by comma in a column?

I am looking to return a value in a database. Table named TIPOLOGY is structured like this: Name Owner ID Office Type LIST_OF_VALUES Jones Lasi 1 12345 TKT AUD,PAX,CCF ...
1
vote
2answers
148 views

novice-design: Are FOREIGN KEYs always necessary? Joins on columns which are not PK

I've been wondering if following approach is bad or really very bad:). Question#1: can we use indicator_id to combine data from indicator_values and indicator_details tables (without using FOREIGN ...
0
votes
0answers
34 views

Deleting a Row in Table- Best way to also delete all rows it affects? [on hold]

I have created a very simple SQL script (see below) that deletes rows in my table if a column name is a certain value. DELETE FROM table_name WHERE some_column=some_value; However, this table ...
0
votes
0answers
24 views

Next date to be displayed [closed]

train depature and arival arv dep day 13:40 pm day 1 20:45 pm 23:20 pm day 1 02:20 am day 2 I need the output as (give input as ...
1
vote
2answers
97 views

Which data type should I use to store a 11 digit number [closed]

Which data type I should use to store an 11 digit number? It must store '0' as the first digit. For example, if I store 02421402015, it must show 02421402015. I tried using varchar and it shows ...
-1
votes
0answers
14 views

Discriminating rows where column start and/or end with dots

I have a table where rows are stored as follow: # id alias_desc state 1 3 Alison a 2 4 Alison. a 3 5 Alizon a 4 6 Alizon. a 5 7 Amada a 6 8 Amada. ...
6
votes
2answers
233 views

Add [Is Primary Key Column] to this query

I made this query, to list tables, its columns, data type and etc: select t.name as 'Table', c.name 'Column', ty.name 'Data_Type', c.max_length as 'Max_Lenght', ...
0
votes
0answers
36 views

What is the best ways to filter data on the fly

We are implementing a new plan for ETL database, but we do not want to store the intermediate table on our local sql server (only want those records that we need). any body know the best ways to do ...
0
votes
0answers
35 views

Headers and footers for Crystal Reports [closed]

I have three tables: Employee [EMPNAME, EMPID] ProductList [ProductName, ProductCode] Orders [EMPNAME, ProductCode, ProductName, DeliveryDate, OrderDate, TOTAMT] I am trying to ...
2
votes
0answers
33 views

Design a many-to-many table for scale

I am thinking about scaling issues with many-to-many join tables. I have a constructed example as following: Many users have many wishlists. On every wishlist are many items. If I scale this ...
0
votes
2answers
25 views

Combine multiple row's records in one row with MS Access Query?

I have a table (name- tbl2) with 21 column but I want to combine multiple rows records in a row by using a unique reference number as below: Table Field and Records Type Expected Result: Please ...
-2
votes
1answer
27 views

Select into statement

Is it possible to use "select into" statement when we are joining different tables which have 1 or more same column names? Eg: Table1 has column name as description and Table2 has column name as ...
0
votes
0answers
15 views

Sum data from 3 tables(joining), but one of may no data then other tables data will show

I am making a stock group summary report for this I am making Sum data from 3 joining tables, but one of may no data then other tables data will show. I have 3 tables as: ac_stock_item, ...
3
votes
1answer
73 views

Aggregate data from multiple rows into single row

In my table I have rows, and each row has some data and its version. When column is not-null, it overrides an old value otherwise nothing happens. Pseudocode (in C#) var resultTable = new ...
-2
votes
0answers
15 views

Select a Record with multiple status entries in same table [closed]

I have a table that carriers Status of members . A member record can have multiple statuses for example Eligbile, Invalid.. etc. I only want to select members from the table that have only two ...
-2
votes
1answer
59 views

Fatal error when not numeric value - PostgreSQL 9.2 [closed]

Below is an example of the auto-generated update query, with client-supplied keys (_iid). There's a fatal error when _iid is not numeric. However; this should accept any value. I believe that's what ...
-1
votes
0answers
27 views

Counting outdated records

I would like to know if I am able to add a subquery that will sum/count outdated ( FROM zlec ). The field that contains the date is zlec_do, and the type is datetime as such 0000-00-00 00:00:00. The ...
-2
votes
0answers
18 views

Can you please explain about Remedy ticketing tool [closed]

Can you please explain about Remedy ticketing tool
0
votes
0answers
20 views

ORA-01745: invalid host/bind variable name using ORACLE [duplicate]

With my below debugged query, I got error as ORA-01745: invalid host/bind variable name Here is the query, SELECT DISTINCT sv.mkey, vehicle_no, TO_CHAR (date_in, 'dd-MM-yyyy') || ' & ...
0
votes
1answer
20 views

Database for live mobile tracking [closed]

I'm developing an app that allows to track a mobile device instantly (live) ... I need an of advice. The application must send the location to a webservice that in it's turn records the received ...
1
vote
1answer
41 views

Does the function inside the Select clause evaluate the passed in columns before the where clause?

I have a simple select statement that uses a (not so) simple function. I'll try to simplify and demonstrate to the best of my abilities for purposes of this question. select ...