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

Trouble With Basic Query Searching

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
0answers
23 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
19 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 ...
1
vote
2answers
39 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
19 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
24 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
22 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
19 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
28 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
132 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
33 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 [on hold]

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

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

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
228 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
34 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
34 views

Headers and footers for Crystal Reports [on hold]

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
20 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
25 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
13 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
71 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 [on hold]

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

Fatal error when not numeric value - PostgreSQL 9.2 [on hold]

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 [on hold]

Can you please explain about Remedy ticketing tool
0
votes
0answers
19 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 [on hold]

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
40 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 ...
0
votes
0answers
16 views

SQLite3 query question [closed]

I'm using the Ghost blogging platform (https://ghost.org/ its very nice) and I'm trying to make an external site, which accesses its database. The relevant tables, and their relevant columns for my ...
0
votes
1answer
19 views

PostgreSQL, how to query the database to retrieve the percentile elements of a dataset?

I need a PostgreSQL query that do the following job: given a percentage (e.g. 10%), the query should return each 1st element of each percentile, among all the elements selected. So suppose in this ...
2
votes
2answers
119 views

How to get data from three different tables

This question is continuing of this issue: How to get data from two different tables? Now I need to connect the table Sessions with 2 tables: Input Downloads When I use this query with real ...
-1
votes
0answers
29 views

Question Regarding Full outer join and excluding null values from tables [closed]

How to remove null value after joining 3 tables using full outer join?
6
votes
2answers
120 views

Selecting Distinct Rows but Counting All Rows

I have the following table: ---------------------------------------------- | ID | interestingData | timestamp | ---------------------------------------------- | 1 | 400 | ...
3
votes
1answer
34 views

Howto combine UNION with EXISTS?

I have a query that looks like this: SELECT PubKey, Title FROM Publication UNION SELECT NoteKey, Title, FROM Note Which works fine. My trouble start when I try to add an EXIST to it: SELECT ...
3
votes
2answers
56 views

How to trim first digit off an integer value?

i have data like Column1, i want to convert the Column1 data as Column2. Can any one suggest to me how i can achieve this in SQL? Column 1 Column2 1000001 1 1000002 2 1000003 ...
1
vote
1answer
55 views

Data structure design for supporting arbitrary number of columns in table or database [on hold]

I am currently working on a sort-of a meta-modeler to build a free web service so that people can input data and run several models on that data. The task I am currently struggling is: user needs to ...
7
votes
2answers
78 views

SQL Server 2014 Sudden Slow Down / No inserts/ Not related to hardware or index

I'm running a 350GB database on my PC with ~40 million rows. SQL Server 2014, Win7, AMD 8350 @ 4.8GHZ, 16 GB of RAM, and a 500 GB SSD (database is hosted on it's own 500 GB SSD, with a ...
0
votes
0answers
44 views

Index Maintenance taking long time - Primary Key (Clustered Index) Varchar(35) [closed]

I have a table in my database that contains around 70 Million rows. Unfortunately the database designer had made the primary key (Clustered Index) column of type : Varchar(35). Obviously this is ...
1
vote
1answer
16 views

SQL Always on Availability LSN Query

Please can somebody explain how the following works: Scenario: Two nodes in always on availability group configuration (all databases). If I have a backup job on node 1 to backup Full and Log ...
3
votes
1answer
140 views

How to get data from two different tables? [on hold]

I have these two MySQL tables: tab1: +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | ...
0
votes
1answer
42 views

I don't want to have the error when I drop a table although the table doesn't exist [closed]

I am using Oracle 12c and I am not interesting to have an error while droping my table 'CONTINENT' in case it doesn't exist. I did this set echo on set serveroutput on alter session set ...
0
votes
0answers
31 views

How can I display values as columns dynamically using postgresql

I have a data table containing finance data about some filings like: filing_id | custom_label | value ------------------------------------ 987345 | cash | 567 987345 | ...
0
votes
2answers
64 views

Can Oracle 11g Express Edition Work on Parallels

I am using a Mac and need to use Oracle 11g. I have Parallels installed with Windows 8.1 on it. Do I need to download anything else or just download Oracle 11g Express Edition and run it?
1
vote
1answer
36 views

Postgres CTE query for a single row not optimized

From my database I am trying to get a weighted sum of a user's stats, and I will only be querying the table one or two users at a time, so I wrote it as a view. Since it's a view, I pretend to ...
0
votes
0answers
21 views

Undcipherable SQL error [closed]

In a introductory Databases class and am suppose to input the following SQL statement into MS Access: SELECT Count(*) FROM SKILL JOIN CERTIFIED ON SKILL.SKILL_ID = CERTIFIED.SKILL_ID WHERE SKILL_NAME ...
0
votes
1answer
37 views

difference between assingment and : [closed]

what is the difference between these two ,second is arithmetic expression assigne to sal , first one is ? how they differ exactly. if salary has intial value of 10 both result same answer. when to ...
0
votes
0answers
28 views

Mulitple counts each one in 1 column with one group by column [closed]

what is the best option to create a report with multiple counts to show how many records were saved, registered, created, etc by Organization. Each organization would have your own row with the count ...
0
votes
1answer
29 views

Restore from SQL Server 2014 Enterprise to BI

Is it possible to restore a SQL Server 2014 Enterprise database with table partitioning (Production) to a SQL Server 2014 BI Version (Test/Development) ? Of course I don't expect to use the table ...
1
vote
1answer
27 views

How to get particular object from jsonb array in PostgreSQL?

I have a field called 'user' that holds a json array that roughly looks like this: "user": [{ "_id" : "1", "count" : "4" }, { "_id" : "3", "count": "4"}] Now I want a query like: select count ...