Get the first N lines per day in Hive - rank ()

I have this table, each row donating a sale: sale_date salesman sale_item_id 20170102 JohnSmith 309 20170102 JohnSmith 292 20170103 AlexHam 93 I'm trying to get the top 20 salesmen per day and I came up with this: SELECT sale_date, salesman, sale_cou

SQL query and Group By

I have table material : - id: int - Product: varchar (100) - Content: text - price: double I would like to display list of materials with a group by product with the last price I tried with: SELECT * FROM materiel GROUP BY produit ORDER BY id But it

OPTIMIZE SQL QUERY WITH NOT EXISTS

I have 4 tables, F_NSE, F_LTR, F_TRA, INVENTARIO. Table INVENTARIO contain data for last stock for a product. F_NSE is table for product trazability (bacth date,..), F_LTR contains data for product selling and F_TRA contains data on the INVOICE. I ne

How to round the timestamp to the number of days?

PreparedStatement psnmt=con.prepareStatement("SELECT (?)-(?) as DiffDate FROM dual"); psnmt.setTimestamp(1,ctenderdate); psnmt.setTimestamp(2,btenderdate); ResultSet resrt=psnmt.executeQuery(); if(!resrt.next()) { out.println("No Records Fo

SQL command and selection of a nearest value

I have a multiple tables and connecting each tables. Result like that: CarId CarLat CarLon Path Minute Distance 325 36.000 37.200 H4 74 250 344 36.050 37.040 H6 75 500 365 36.300 37.600 H4 76 750 311 36.060 37.080 H5 77 800 As you can see, path have

Date format conversion to execute a select statement

For a program I am writing (In Java) for school I have to run a select statement between to dates to produce a timetable. This selects data from SQL and puts it into a table. My problem is that the data type date is in the format 'YYYY-MM-DD' and the

How do you join three tables in Oracle?

I'm having a hard time joining three separate tables in Oracle. I'm never joined three tables before so I'm not well versed. My theory is below: SELECT customer_num WHEN customer_num IS 104 -198, order_num FROM orders INNER JOIN items ON order_num, s

to create a table in Oracle DB but gives an error

CREATE TABLE employees ( id INT NOT NULL auto_increment PRIMARY KEY (ID), first_name VARCHAR(20) DEFAULT NULL, last_name VARCHAR(20) DEFAULT NULL, salary INT DEFAULT NULL); I think this is correct query to create table in Oracle database.. but it giv

I need to merge entries with one table in mysql

Have to get this result for the following problem in mysql For example this table contains, values for columns month, amt1, amt2, amt3; if amt1 has values then amt2 and amt3 will be null and similarly for amt2 and amt3. All columns are VARCHAR But th

Data type error on the prepared execution plan

I have the below error, this error only happens in the second execution cause the planning cache ERROR: el tipo del parĂ¡metro 11 (character varying) no coincide aquel con que fue preparado el plan (text) Where: PL/pgSQL function graficar(character va

Additional requirement in the SQL join

Assume that we have two tables in SQL database (I'm using PostgreSQL in case the answer depends on the database): CREATE TABLE testA ( id integer, checked boolean ) CREATE TABLE testB ( id integer, testA_id integer ) I want to do a select from testB

Get the identity after selecting a separate result

i have 2 tables ( Model_Table , Items_Table) Model_Tabl ( ID, ModelName, ModelQuantity) Items_Tabl ( I_Code, IName, ID) after inserting new row into (Model_Table) - Triggers insert multi row into (Items_Table) Depend on ModelQuantity from (Model_Tabl

SQL statement using a special charter

Can anyone please help me in correcting below statement: SET @cmd='BULK INSERT ' + @Database + '.dbo.' + @tmp + ' from ' + @Out + @tmp + '.csv WITH (FIELDTERMINATOR = , , ROWTERMINATOR = \n)' Output of the above query is: BULK INSERT MP2.dbo.GLCODE f

Two chainlines for a pointer

Possible Duplicate: How to split a string literal across multiple lines in C / Objective-C? Sometime I have to write several SQL statements pointed by char variable like: const char* sql="CREATE TABLE GenInf ( EmpName TEXT NOT NULL, Pyrll TEXT PRIMAR

Equivalent of Order By operation in HBase

Am working on a project which uses HBase. Even though I formed the rowkey as good as possible, still in some scenarios I need to get the results in either ascending or descending order. Is there anything in HBase which is equivalent to "order by"

MS Access SQL does not work as desired

I have a query which goes like this. SELECT * FROM <database1> WHERE (Condition1) AND (Condition2 or Condition3) My desired result should be rows satisfying condition1 and rows satisfying either condition 2 or condition3. But the SQL is giving me ro

Executescalar Query Code Problem

Im trying to return the member id in this query below. If i run the query as just as a query i get 20 but when i exectute the code it returns a zero. What am i doing wrong here? public int GetMemberID(string guid) { string strConectionString = Config

Importing a large SQL file

I've seen a lot of questions regarding this topic, but going through these didn't help so I'm asking.. I have a large sql file (around 50mb) which I cannot import using phpmyadmin as it's limited to 2.5mb. I've tried to use bigdump and I'm getting an

sql question about debugging a request

I have a stored procedure that returns multiple columns. like colA colB colC .... colL Can I write another query to get the same columns but if colC/colB <10% i.e WHERE filter by 10%. Basically the same columns as returned by the stored procedure sho

Get the unique value of a set of SQL results

Consider this SQL query $sql = "select count(*) as count from table where value='this'"; This query is going to return only one value in the field count. Is there a way to get that value without using a fetch_array and pointing the first value o

C # - Website - SQL Select Declaration

I want to use a select statement to find if there is a record that already exists. I've put the code below but it throws an error at the dReader = comm.ExecuteReader(); and i'm unsure why. Any help? string connString = "Data Source=KIMMY-MSI\\SQLEXPR

Join two tables on the same server

I have two databases at the same server 192.168.1.100 DB1 and DB2 When I'm trying to execute : select h.code,eh.Defaultname From hotels h JOIN [192.168.1.100].[dbo].[DB2].Hotels eh ON h.code = eh.code I get Could not find server '192.168.1.100' in sy

What is the difference between cn.execute and rs.update?

i am connecting to mysql from excel using odbc. the following illustrates how i am updating the rs With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = ati