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

learn more… | top users | synonyms (1)

0
votes
1answer
20 views

Does @@FETCH_STATUS have (or need) an equivalent to SCOPE_IDENTITY?

MSDN advises that @@FETCH_STATUS be used with care because it's global: Because @@FETCH_STATUS is global to all cursors on a connection, use @@FETCH_STATUS carefully. After a FETCH statement is ...
-4
votes
1answer
13 views

How long to keep order data in tables in a database [on hold]

How far back should you store data and when should you move the data off the production eCommerce site to a data warehouse? Can someone provide some links. I would think you would want to keep your ...
0
votes
1answer
29 views

SQL Query; Admin Log System; Foreign Keys; Retriving multiple rows form different tables at once

Table A (users) id | name | ip 52433 Yashas 1.1.1.1 512 Admin 5.6.7.8 Table B (admin_record) id | admin | time | date | reason | action 52433 512 2312352 ...
0
votes
2answers
30 views

Database Design - Voting System

I'm creating a website in which people can submit there own lists, and then essentially others Up/Down Vote the items within the list. I'd like the list (If the submitter allows "votes") to be ordered ...
1
vote
1answer
25 views

Filter created_at and count distinct minutes

I have this query to get records from a database: SELECT camera_id, count(*) AS snapshot_count FROM snapshots WHERE created_at >= timestamp 'yesterday' AND created_at < timestamp 'today' ...
0
votes
0answers
19 views

SQL Server service automatically stops after starting I cant lo in to sql database engine [on hold]

It worked fine until now. I can't get it working because SQL Server service automatically stops immediately after I start it. I'm trying to start it from Sql Server Configuration Manager. When I open ...
0
votes
0answers
11 views

Question on comparing two fields in Access

I'm not sure if the title is fitting as I am not 100% sure if what I am doing is correct but here goes. Here is my enrolment table, I have added a field called pass/fail as you can see which is ...
1
vote
4answers
44 views

Selecting data from another table using a foreign key

I have two tables A & B. Table A id | name | num Table B id | date | roll id in table B is a foreign key which relates to the id in table A. I want to get the contents of table B where id ...
0
votes
1answer
33 views

Query that compares dates

I'm trying to create a query that shows if students are mature or not, based on their date of birth. However when the query is executed it returns all students as not mature. Any students that are ...
0
votes
1answer
22 views

Unique identifiers for the same type of object in the same request

This question is about your opinion and common approach for relational databases. So please, do not vote me down. I really need to solve this problem.. I remove this question once I meet the answer. ...
0
votes
1answer
32 views

How can I optimize my SQL Query

I try to optimize a Sybase SQL Anywhere Query for Performance but with no luck. LetzterPreis & LetzterBeleg slow it down. Any suggestions how I can optimize it? :( Here is the query: SELECT ...
3
votes
1answer
48 views

How to use a CASE expression in the WHERE clause?

I am using a CASE expression in my WHERE clause like this: SELECT * FROM ASPECT.WR_AM_ADT_SUMM INNER JOIN ASPECT.WR_AM_DLR_DTL ON AS_CNTRY_CD = DD_CNTRY_CD AND AS_DLR_CD = ...
-5
votes
0answers
32 views

I want to write query as per business requirement [on hold]

Universe Addition for Historic Data: Expired Contact Company Associations with companies as defined in universe, provided the record has either Committee or Compensation info, and belongs to Company ...
2
votes
1answer
35 views

Increase date by 1

I have a query that fetch whole year record and sums up the count.The query is as follows select count(*) as t, m.machine1 from sap_prod_data s left join sap_machine_speed m on s.mch_desc = ...
0
votes
1answer
50 views

Microsoft SQL Server Vs Oracle [on hold]

I'm working in SQL Server as database administrator/Developer, and currently I was thinking about oracle. Many people said that it is a future and we will have more oracle databases then sql server. ...
0
votes
0answers
19 views

Optimize Query - PostgreSQL 9.2

This is related to my previous Question: slow-query-optimize-postgresql The new Query is good, the missing piece is that the quantity & cost selectors are interchangeable (in code) with: if ...
0
votes
1answer
11 views

Access IFf Query

I'm new and just starting out at creating databases so I apologise if noob question. What I am trying to do is update my Staff table to show that "Sarah Avon" has married and her new last name is ...
0
votes
0answers
4 views

Forcing OBIEE to Act Like Excel… If, Then, Else Evaluates ONCE

I get duplicates that I do not want using the following expression with the subsequent data: Case When Locate('Stuffed',"Journals"."Journal Text") > 0 THEN 'Stuffed' When ...
0
votes
0answers
12 views

Enabling the use of OPENROWSET in Sql Server [duplicate]

I am trying to make my DEV Server allow the use of OPENROWSET. Though I can use it on my production but not in my DEV. I cannot use the Bulk insert because the excel file is dynamic (Column changes ...
2
votes
2answers
40 views

Generate a sequence of timestamps but skip given periods

I have a table things_to_do in PostgreSQL. For example: thing_id --------- 1 2 3 4 5 6 And I want to add a timestamp to every row: SELECT thing_id, '2016-02-10 19:57:00'::timestamp ...
0
votes
0answers
14 views

How to properly implement a relationship between a table with an array of foreign keys and the foreign table? [duplicate]

I'm not entirely sure how to implement this kind of relationship correctly. As an example, assume that we have: CREATE TABLE menu_item ( mi_name TEXT PRIMARY KEY, mi_ingredients TEXT[] ); ...
0
votes
2answers
19 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 ...
4
votes
4answers
168 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
1answer
41 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 ...
1
vote
1answer
43 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
66 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
15 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
28 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
20 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
1answer
42 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
38 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
72 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 ...
3
votes
2answers
88 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
20 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
45 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
31 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
57 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
58 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
1answer
92 views
+50

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 SQL Server 2012 - Need to connect through a VPN. We setup a local Server with with ...
0
votes
2answers
41 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
80 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
57 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
25 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
64 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
29 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 [closed]

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
26 views

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

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
22 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 ...