Creating a view and replacing id with strings of text values
This can be a pretty basic question, but I'm a newbie so any advice is appreciated.
Here's my data:
create table user_attributes (id NUMBER, attr1 number, attr2 number, attr3 number, attr4 number, attr5 number); create table tag_values (tag_id number, tag varchar2(30)); insert into user_attributes (id, attr1, attr2, attr3, attr4, attr5) values (1, 101, 105, 102, null, null); insert into user_attributes (id, attr1, attr2, attr3, attr4, attr5) values (2, 105, null, 101, 105, null); insert into user_attributes (id, attr1, attr2, attr3, attr4, attr5) values (3, 102, null, null, 105, 103); insert into tag_values (tag_id, tag) values (101, 'blue'); insert into tag_values (tag_id, tag) values (102, 'red'); insert into tag_values (tag_id, tag) values (103, 'green'); insert into tag_values (tag_id, tag) values (104, 'orange'); insert into tag_values (tag_id, tag) values (105, 'black');
I want to create a view and the column id and the text of the tag instead of the ID.
That's what I use so far (just showing three columns of attribute for example):
SELECT a.id, b.tag ATTR1, c.tag ATTR2, d.tag ATTR3 FROM user_attributes a LEFT JOIN tag_values b ON a.attr1 = b.TAG_ID LEFT JOIN tag_values c ON a.attr2 = c.TAG_ID LEFT JOIN tag_values d ON a.attr3 = d.TAG_ID ORDER BY 1;
Result:
ID ATTR1 ATTR2 ATTR3 ---------- ------------------------------ ------------------------------ ------------------------------ 1 blue black red 2 black blue 3 red
That's what I want, but I have a lot of data and I want to just make sure that I do things properly. Is there a more efficient way to build this application?
Hello
It would be so much easier if you had only 1 column to search, not 5. We will therefore unpivot the table so there is only 1 column to search; then we can switch it to display as you wish:
WITH unpivoted_data AS
(
SELECT ua.id, ua.col, tv.tag
Of user_attributes
UNPIVOT (attr
FOR the collar (attr1, attr2, attr3, attr4, attr5)
) ua
JOIN tag_values tv ON tv.tag_id = ua.attr
)
SELECT *.
Of unpivoted_data
PIVOT (MIN (tag)
At THE neck ('ATTR1' AS attr1
'ATTR2' attr2 VALUE
'ATTR3' attr3 AS
'ATTR4' AS attr4
'ATTR5' AS attr5
)
)
ORDER BY id
;
Output:
ID ATTR1 ATTR2, ATTR3 ATTR4 ATTR5
--- ----- ----- ----- ----- -----
1 red blue black
2 black blue black
3 black red green
.
It is better to have the attributes in a dynamic no cross-form for this problem, it is perhaps better to have the attributes of the dynamic non cross-shape for most other uses, too. Consider to permanently store the attributes with only 1 attribute per line.
Tags: Database
Similar Questions
-
Based on http://forums.Adobe.com/thread/1308132?TSTART=0 I decided to add each question separately:
Hello, I am very interested in buying Lightroom 5.2. I tried the RC that was missing today. Yet, I have several questions that I can't find really good conclusive answers, I'd like to get an answer before buying LR. Please do not write maybe like this or that (assumptions), because I don't want to start my entire workflow and then realize that I have to change all around, please reply, if you know for sure that something works and you are, preferably, using this method too.
Can I create a snapshot and replace it with an image (or link another picture than the current photo)? Details: I made adjustments in iPhoto until now I want my (unpublished) masters, some RAWs JPEGs, create a snapshot and set the photo as the one to keep. If it is not possible, all of the recommendations (in addition the usual masters of backup and import changes).
What I do is I have to assign some metadata down battery photo indicating of don't not to export the picture. Then, I use either a collection of smart to find the photo I want to and can not find the photos, I don't want and export all in the smart collection. or I use a Collection of post Smart, even once allows me to select only the pictures I want and not those I want.
Of course you manually uncheck items you want to export, which work as well.
-
Find and replace the delimited string value by the
Hi all
I have a requirement where I need to find and replace the delimited string values.
For example, the string is "GL ~ 1001 ~ 157747 ~FEB-13~ CREDIT ~ A ~ N ~ US ~ NULL ~". The 4th column gives the month and year. I need to replace it with the name of the previous month. For example: "GL ~ 1001 ~ 157747 ~JAN-13~ CREDIT ~ A ~ N ~ US ~ NULL ~". I need to do the same thing for the past 12 months.
I thought initially divide the values and store it in a variable and then after him substituting the value required, join the return.
I just wanted to know if there is a better way to do it?
Like this:
with a model like
(select "GL ~ 1001 ~ 157747 ~ FEB-13 ~ CREDIT ~ A ~ N ~ $ ~ NULL ~' double UNION ALL data")
Select ' GL ~ 1001 ~ 157747 ~ JAN-13 ~ CREDIT ~ A ~ N ~ US ~ NULL ~' double data)
Select
REPLACE (DATA, TO_CHAR (to_date (substr (data, 16.6), "MON-RRRR"), 'MON - RR'), TO_CHAR (to_date (substr (data, 16.6), "MON-RRRR")-1, 'MON - RR'))
modeling;
GL ~ 1001 ~ 157747 ~ JAN-13 ~ CREDITS ~ HAS ~ N ~ US ~ NOTHING ~
GL ~ 1001 ~ 157747 ~ DEC-12 ~ CREDITS ~ HAS ~ N ~ US ~ NOTHING ~
Ishan
-
Hello. When I search on Safari, it freezes in the following situation: I have run a search by typing in the search bar. The search results I get, it's not what I wanted, so I erase the question of search and replace it with another question of research. Instead of a new search result that Safari freezes. What is going on?
IOS 9.2.1 does not run on iMac, as shown in your profile. If you want to help, at the very least, we need to know that the version of Mac OS X installed. If you are not sure, please click on the Apple symbol in the upper left of the screen and select about this Mac.
-
How can I remove my OS and replace it with windows on my macbook pro 10
How can I remove my OS and replace it with windows 10 on my macbook pro?
Primarily, I use my ipad pro for all my work and I want a windows dedicated for other work machine.
What os? you want to replace the OS X 100% with windows with no return back?
or you want to replace a version of windows in bootcamp with windows 10?
your macbook must support windows 10 in any case, you can read here more use 10 Windows on your Mac with Boot Camp - Apple Support
-
Search in a table by a negative number and replace it with a zero
Hello
I want to search in a table (dual 64 - bit) for a negative/s number and replace it with a zero.
BR
Probably the fastest option in this case
-
Hey!
I know that you can remove a dvd cart and replace it with a HD you can get a sata adapter and change a PCI express so I can install a graphics card in the caddy hd for my laptop. y at - it means to get an internal or external graphics card? I do not have a slot express pci laptop because a laptop is relatively new.
Original title: laptop computer graphics cardother cool mods I can do for my laptop. I've already upgraded to ssd and ram and processor.Hello
I do not know such an adapter exists, but it's a hardware problem - I suggest you contact the manufacturer of your laptop with this issue, as well as questions about additional upgrades, you could do.
These are all the hardware problems, and this site deals with software issues related to the Windows operating system. I'm sorry this isn't the answer you're looking for, but...
Let me know if this helps you.
Kind regards
BearPup
-
I can't uninstall the old silverlight and replace it with the new version.
Im trying to uninstall the old version of silverlight and replace it with the new. It won't let me uninstall. Help, please
Hello
1 have had any changes made on the computer before the show?
2. do you get an error message? If Yes, what is the full and exact error message?
Method 1:
I suggest you for the link and check if that helps:
Uninstall previous versions of Silverlight on Windows
http://www.Microsoft.com/getSilverlight/get-started/install/uninstall-win.aspx
Also check out the link to install Microsoft Silverlight:
Download Microsoft Silverlight
http://www.Microsoft.com/getSilverlight/get-started/install/default.aspx
Method 2:
I suggest to consult the article and try to uninstall the program:
Diagnose and solve the program installation and uninstallation problems automatically
http://support.Microsoft.com/mats/Program_Install_and_Uninstall
Let us know if it helps.
-
Original title: recovery of original windows 8
When I bought the new device, it was loaded with windows 8 but a few days before my hard drive has been corrupted and replaced it with the new hard drive but could not get the real Windows back 8.
Please help me to get my windows genuine 8 back so I could get additional updates downloaded.
Hello Vishal,
Welcome to the Microsoft community. I appreciate your efforts to resolve the issue. I will certainly help you with the problem you are experiencing.
If you purchased a computer with installed OEM Windows 8 on it, there could be a sticker on the Tower, or in the back (in the case of a laptop) with the product key to this topic. If there is no sticker, he can be preinstalled on your system BIOS.
See the suggestions posted by Andre Da Costa replied on March 7, 2013.
In addition to this, see:
Product key lost or misplaced (certificate of authenticity) for Windows
If the problem persists, you can contact the manufacturer of the hardware for the same thing and check.
Hope this information was useful.
-
Once again! Why?
It takes too much time. All I want to do is remove a sentence and replace it with another.
Please see this link for a list of the forums. You can post your specific questions of the application in the forum that supports your application.
FAQ: Where can I find creative clouds of the forums users to search or ask a question?
-
I accidentally buy the windows version of adobe acrobat DC instead of the mac version I only a mac computer can you please cancel my purchase and replace it with the version of windows with a mac version. the order number is AD006058877NL. Rgds, jan van montfort + 31681471049. [email protected]
Hi Jan,
I understand your concern, please see this doc on this subject: return, cancel or change an Adobe order
Kind regards
Rahul
-
creating a view and use the view in a model
Hi all
I'm new to OBIEE, and I have a requirement that I have two fields to be added to a domain. Because we cannot add queries directly to a model, I have to create a view and then put the request in it, and then use the view in this model.
I did not understand this well, if someone could help me, explaining in detail the view and adding a query in it?
Thank you
GohanHello
(a) If you want to use your existing DB view please tick box import meta option data - RPD--> file menu
(b) If you want to create the new view in RPD itself just right click anyof a physical table--> properties--> click the genral--> change the type of array as "Select" then you create/update your sql query, and then click ok that's all
Once created, you can deploy advice on the database (right mouse button) or you can leave the view cancelled (worst performance).Ref steps more to create views
http://gerardnico.com/wiki/dat/OBIEE/opaque_view
http://allaboutobiee.blogspot.com/2012/05/OBIEE-11g-deployundeploy-view-in.htmlThank you
Deva -
Create Materialized view and Materialized view log.
I wanted to create a materialized view with option "REFRESH QUICKLY YOU COMMIT".
(1) table 1 - it is partitioned range + list - added primary key
(2) View1 - having primary keys on the base table of view
Steps to follow:
(1) create the materialized on Table1; view journal -primary key by default
(2) create the materialized on view1 view log. -It gives below error.
ORA-00942: table or view does not exist
I wanted to create Materialized view as below
create a materialized view
Quickly REFRESH ON validation
as
Select...
........
... from table1
where c1 (select c1 from View1 which...);
Question:
(1) because I am getting above error when creating journal of MV on the view. Can one create log view MV or we create a MV newspaper on the base table of view?
(2) to create the MV with "REFRESH QUICKLY YOU COMMIT' option, we need to have the primary key on the main tables?
Pointers on this will be really useful.
Thank you
Prasad
"When a materialized view is maintained by the
ON
COMMIT
method, the time required to perform the validation can be slightly longer than usual." This is because the refresh operation is performed as part of the validation process. This is why this method may not be suitable if many users at the same time change the tables on which is based the materialized view. »See: basis of materialized views (refreshment options) for all the other options and how they work.
-
I intend to buy the iPhone, which will be released this morning, and I heard that the next iPhone will run out quickly, the configuration I wanted, as 6s and 6 s iPhone more runs so quickly, but this time, I want to start from the beginning because I don't want to miss a day of work, or otherwise I won't get it that $5000 per day , so if I don't have a number to AT & T, what do I do because I am on T-mobile, and I can't go to the Apple Store Friday on time to conduct a review of YouTube and get views and re-read soon on my site. I am currently on AT & T, but I heard that the iPhone is going to be better with the upgrade program, and I wanted to sign up. So, why do you need an AT & T number, and why should I go to the Apple Store if I want a T-mobile and last year, I had to wait until October 9 to get my 2nd iPhone 6 s more of Apple and a back of pre-orders unlocked without AppleCare.
Nothing is still announced by Apple, but wait like everyone else.
-
How to get rid of Windows 8 and replace it with Windows 7
I bought my HP Pavilion laptop G6 in December 2012, when all the they had was Windows 8 machines. So I thought I would give it a try. Well, I have 8 months now and I still hate Windows 8 . I want to replace it with Windows 7, the latest stable known operating system launched by Microsoft. But I heard that recent material doesn't have even a device to support Win7 drivers.
Is there something I can do?
Thank you
-ken
Hi Ken,
There is no reason that you should not be able to install and run Windows 7 on your laptop.
While it is true that HP provide no Windows 7 drivers for machines shipped with Windows 8, you should always be able to find all the relevant Win 7 drivers, you will need.
What is the complete model number and your notebook series g6 Nr? -See here for a guide to the location of such information.
Kind regards
DP - K
Maybe you are looking for
-
Problem intermittent boot Tecra S2 after pressing the power button
Hi allI have a Tecra S2 with the 6600go GFX card.The machine is large but presents the following problem. After that the machine was interrupted for a while it will start not reliable.You press the power button. Either as soon as you release the powe
-
Windows Media Center, download Guide Erroe Code 3
My Media Center does not download the info guide, claims error Code 3
-
Hello everyone, this is going to sound stupid, but iot today I tried to learn more about my computer and something out about half of the desktop icons changed to the same as Windows media. I tried what I can and I have no chance, would someone please
-
Custom time frequency of update of Security Intelligence
Is it possible create the frequency of update 1 m, 5 m for a list of pet food?
-
D-Link USB modem Model: DWM - 156
Inoperative modem USB D-Link Model: DWM - 156. I've used it before, but now only my PC not read it!