I am trying to get the most recent record(s) with a status of Registered, Expired, using the status date value to get the latest one. The query I have , I am using a specific lot number that has 13 …
Tag: sql
Update Oracle table column with a sequence number based on varchar field in same table
I am in need of help with the syntax to update an existing field in an oracle table with a new number sequence based on the ordering of another field that is VARCHAR2. Current Table: CODE …
SQL does not recognize tablename from select statement
If I write the tablename after ‘FROM’ the query works. If I use the result of a select statement the query does not resolve. Is there a workaround? I have tried resolving the tablename as an output …
Create a view in SQL Server and lookup with another table
I’m very new to SQL and am trying to create a view in SQL Server using 2 tables. There are some conditions will impact the way of selecting data and I would appreciate some guidance on what’s the …
Putting a sql table into python error. Whats wrong?
I would like to know what’s going on with this query. Im not able of put it into a pandas data frame. The error description is “IndexError: tuple index out of range” i = 3 query = (“SELECT COL1, …
hibernate multiple @OneToMany relationships generating more results in parent relationship
I will start with the result. In the next image I am displaying the result content of company.userAccount. In the database I have only two companies assigned to the same user and 7 services attached to one of the companies. The generated query (simplified) is This will generate Expected result: I was expectin…
Trying to write an inner join to filter out some conditions
I’m currently struggling with carrying out some joins and hoping someone can shed some light on this. I have three tables: A,B,C Table C lists names of individuals Table A lists the food they …
how to get different date ranges for the last One year as per sysdate
I have a scenario: as per my sysdate i need to capture last 12 months dates. Example: I will be getting a parameter which is numeric like : 2,3,4,6 .. If the parameter is 3: then as per sysdate-12 …
Conditionally add a column with a default value to an existing table in SQL Server
I want to add a new column in existing SQL table with default values depending upon some cases/conditions. I want to know if this is possible. If yes how? if not why? Alternative : One option is …
Group rows in Oracle using PARTITION BY
I have below 2 tables which i want to display like shown result Data Table 1 id col1 col2 t1 data1 data2 t2 data3 data4 Data Table 2 idOfTable1 col3 col4 t1 …