Skip to content

Tag: sql

SQL Join based on a column value

I want to Join different tables based on column value if [dbo].[fin_FixedAssetRegister].TransactionType = ‘IOD’ then join [dbo].[sms_IssueOrderDetail] if [dbo].[fin_FixedAssetRegister].TransactionType = ‘GRND’ then join [dbo].[sms_GoodsReceivedNoteDetail] if [dbo].[fin_FixedAssetRegist…

Replacing a subquery in a PL/SQL trigger

I have 2 tables. One called Employee and the other Employee_jobs. One of the fields in the Employee table is job_name. The Employee_jobs table contains 2 fields, job_name, and Emp_count (number of employees per job). What i’m trying to do is whenever i perform an operation on the Employee table then it …

Case statment with join-sql

I have a table User which has many messages and many contacts. The relation between messages and contacts table is made trough contactMessages table. Table messages has a foreign key on contactMessages which is the message_id Table contacts has a foreign key on contactMessages which is the contact_id Each mes…

Unpivot or transform data using MS Access Query

Good afternoon guru’s! I’m hoping someone with Access & SQL experience (and time) would be able to write some SQL code that I could use in MS Access to transform/unpivot some data. I guess it’s a bit like a an unpivot. Current table “tbl_Weekly_Forecast” is structured like th…

Select from multiple tables with group and join

i have 4 tabels drinks, opskrifter, ingredients and stock the tables consist of drinks drink_id name beskriv glas image alcohol opskrifter drink_id ingredient_id quantity ingredients ingredient_id name stock ingredient_id name i want a query to select drinks that can be made in opskrifter of the ingredients i…

Generate date from sunday except the existing value, in 1 Week Range

This is the result of my query right now with data getting 1 result only. This is my query: $merid=20; I am trying to populate to get the dates the full week beginning Sunday except the existing Tuesday . Can someone give guidelines on where to begin? Is the logical process can be done here in SQL or do I

Oracle SQL select, compare 2 listagg’s values

I have two tables: one is TEXT_MSG with column ROLES, another one is USERS with column ROLES. Columns ROLES is listagg VARCHAR2, separator is : symbol. It is possible to write SQL statement with WHERE clause to get records from USERS table WHERE one or many roles from TEXT_MSG.ROLES equals role/s from USERS.R…