[Solved] how to group by

WITH sample_data AS (SELECT 1 AS id, 10 AS age, 11 AS name, ‘A’ AS type FROM dual UNION ALL SELECT 2, 0, 1, ‘B’ FROM dual UNION ALL SELECT 3, 9, 11, ‘C’ FROM dual UNION ALL SELECT 4, 10, 11, ‘D’ FROM dual UNION ALL SELECT 5, 10, 11, ‘E’ FROM dual UNION … Read more

[Solved] insert only time in oracle [closed]

You just need basic date arithmetic, and the plain old date type. CREATE TABLE doctor_visits ( doctor_id NUMBER NOT NULL, in_time DATE NOT NULL, out_time DATE NOT NULL ) / I presume you want to find doctors who were in the hospital at 10:00am, as opposed to doctors who visited exactly at 10AM SELECT doctor_id … Read more

[Solved] Load null values in a SQL Query WHERE clause

Your first clause in your WHERE is only going to match rows where died is not null. given that, you can reorder the clauses something like: WHERE first_name NOT IN (‘Hannah’, ‘Julia’, ‘Frasier’) AND last_name NOT LIKE ‘%o%’ AND (nationality <> ‘German’ OR speciality <> ‘Photo’) AND ((died – born BETWEEN 50 AND 80 AND … Read more

[Solved] ORA-00918 Column ambiguously defined [closed]

In your query only USER_ID column in the where condition is not specified with a table name. I guess USER_ID is there in multiple table. Try the where condition with proper table name SELECT INDIVIDUAL.INV_FNAME, INDIVIDUAL.INV_LNAME, INDIVIDUAL.INV_IC_NUM, CUSTOMER.MEMBER_LEVEL, CUSTOMER.MEMBER_POINT_BALANCE, CUSTOMER.MEMBER_DISCOUNT_RATE, PROGRAM_USER.USER_CONTACT_NUM, PROGRAM_USER.USER_ADDRESS, PROGRAM_USER.USER_CITY, PROGRAM_USER.USER_STATE, PROGRAM_USER.USER_ZIP_CODE, PROGRAM_USER.USER_COUNTRY, PROGRAM_USER.USER_EMAIL FROM PROGRAM_USER,CUSTOMER,INDIVIDUAL WHERE PROGRAM_USER.USER_ID = ‘san’; Also like … Read more

[Solved] Oracle NOT pl/sql [closed]

I think you want this: select * from inside_sales where x = ‘equipment’ union all select * from outside_sales where x <> ‘equipment’; Note: The second condition is slightly more complicated if x can be NULL. 1 solved Oracle NOT pl/sql [closed]

[Solved] Sql schema error on create table [closed]

CREATE TABLE ar_abonent ( ar_nr_klienti int NOT NULL primary key , –<– This column needs to be a primary key emri varchar(25), mbiemri varchar(25) ); create table ar_celular ( NR_CEL INT , ar_nr_klienti int FOREIGN Key REFERENCES ar_abonent (ar_nr_klienti) , identifikues bit, data_aktivizimit date, marka varchar(25), constraint chk_celular check (NR_CEL IN (‘35566%’,’35567%’,’35568%’,’35569%’) AND IDENTIFIKUES= 1) … Read more

[Solved] Oracle: Multiple joins with group by [closed]

SELECT * FROM A; A_ID A_NAME A_ADDRESS ———- ———- ———- 1 RAM MO 2 SITA MI 3 JANAKI IL SELECT * FROM B; A_ID B_NAME ———- ———- 1 PAUL 1 KAPIL 2 DAVE SELECT * FROM C; B_NAME C_TITLE ———- ———- KAPIL HONDA KAPIL MAZDA KAPIL ODYSSY DAVE BENZE DAVE LIMOUSINE SELECT a.A_ID, a.A_Name, a.A_Address, … Read more

[Solved] How do I sort the list from database automatically according to the language? [closed]

You can change the way Oracle sorts data by changing the NLS_SORT and NLS_COMP parameter for your session. If you want to retrieve say french data, you can use the following: ALTER SESSION SET nls_comp = Linguistic; ALTER SESSION SET nls_sort = XFrench_AI; select * from my_table where language_code=”fr” order by some_column; Consequently if you … Read more

[Solved] Query sql in oracle [closed]

Your question is a little ambiguous.Is it what you want? SELECT WELL_DPROD_DATE, FORMATION_NAME, CASE WHEN R1 = 1 OR R2 = 1 THEN FORMATION_NAME ELSE NULL END AS FORMATION_NAME_F FROM (SELECT WELL_DPROD_DATE, FORMATION_NAME, RANK() OVER(PARTITION BY FORMATION_NAME ORDER BY WELL_DPROD_DATE ASC) AS R1, RANK() OVER(PARTITION BY FORMATION_NAME ORDER BY WELL_DPROD_DATE DESC) AS R2 FROM DATA_DPROD) … Read more

[Solved] CREATE SEQUENCE IN MYSQL [closed]

Assuming you’re going to Oracle, just set up the statement, parse, and execute. There’s no need to do any binding because you have no bind variables. This is adapted from the PHP documentation of oci_parse: $conn = oci_connect(your username, your password, your database); $stid = oci_parse($conn, ‘UPDATE tableName SET columnName = seq_test_id.NEXTVAL’); oci_execute($stid); 4 solved … Read more