SQL sentence and GROUP BY
Hello:
I have a table with the following facts: ID (autoincrement, primary key), item code, amount, value.
I must select, FOR EACH item, the last ID (max value), the item code, and the division between value and amount just of the register with the MAX(ID).
I think I must GROUP BY item, the dicision must appear in the sentence but not GROUPED BY anything.
Something like this:
SELECT max(ID), itemcode, value/amount
FROM tablename
GROUP BY itemcode
FOR EXAMPLE, if I have the table
1 Potatoes 2 1000
2 Tomatoes 3 300
3 Tomatoes 2 100
4 Potatoes 1 4000
The result should be
3 Tomatoes 50
4 Potatoes 4000
Lots of thanks for your help and excuse me for my los level of SQL!
Hello:
I have a table with the following facts: ID
(autoincrement, primary key), item code, amount,
value.
I must select, FOR EACH item, the last ID (max
value), the item code, and the division between value
and amount just of the register with the MAX(ID).
I think I must GROUP BY item, the dicision must
appear in the sentence but not GROUPED BY anything.
Something like this:
SELECT max(ID), itemcode, value/amount
FROM tablename
GROUP BY itemcode
FOR EXAMPLE, if I have the table
1 Potatoes 2 1000
2 Tomatoes 3 300
3 Tomatoes 2 100
4 Potatoes 1 4000
The result should be
3 Tomatoes 50
4 Potatoes 4000
Lots of thanks for your help and excuse me for my los
level of SQL!Your question is not clear. From the sample data and req o/p that you have given i think you want something like this:
Maximum 2 IDs from a given set of data, their codes and a value => amount/value. Is that what you want?
Jithendra
Similar Messages
-
SQL SUM and Group By Function Wrong Result
Hi All,
I have a SQL view with all the payment transaction for a property per month and trying to sum all the transactions per month per property. For some months the total is not correct. For example for property 3856, in Jan 2014, the total should come to
728 but the query lists 2184.
Trans Date
Amount
Prop Code
31/1/2014
728
3856
31/1/2014
-2184
3856
31/1/2014
2184
3856
Output Required
Year Month Amount Prop Code
2014 1 728 3856
My Query
Select [Prop Code], year(ttp.[Trans Date]) AS [Year], Month(ttp.[Trans Date]) AS [Month], SUM(ttp.[Payment Amount]) as Total
FROM vw_tenant_payments as ttp
GROUP BY [Prop Code], year(ttp.[Trans Date]), Month(ttp.[Trans Date])Hi All,
I got it, it skipped my mind to restrict the payment type to RENT as even the deposit is in the transaction view
Select
[Prop Code],year(ttp.[Trans
Date])AS[Year],Month(ttp.[Trans
Date])AS[Month],SUM(ttp.[Payment
Amount])asTotal
FROM
vw_tenant_payments
asttp
Where
[Account Code]
='RENT'and[Prop
Code] ='3856'
GROUP
BY[Prop
Code],year(ttp.[Trans
Date]),Month(ttp.[Trans
Date])
Order
by[Prop
Code],[Month] -
Hi,
I have two tables with 1 to n relationship.
StudentTable
==========
ID NAME
1 John
2 Mary
3 Peter
SubjectTable
=========
SID Subject
1 Maths
2 English
3 Science
The above two tables are connected with this table
StudentDetials
==========
ID(Students) SID(Subjects)
1 1
1 2
2 3
3 2
3 3
I want to select data from both tables. But I want to select only one row from SubjectTable for each student, even though there are many rows in SubjectTable for each student.
Is it possible to do this with SQL.
Best regards,
Chamal.If you don't care about something specific about this SID's then may be this will help you a bit.
p.s. sorry it's a little rough, but I didn't want to create any tables :-)
select * from
(select id,sid,row_number() over (partition by id order by sid asc) rn
from (select 1 id,1 sid from dual
union all
select 1,2 from dual
union all
select 2,3 from dual
union all
select 3,2 from dual
union all
select 3,3 from dual) t)
where rn = 1; -
Area or view of sql sentences with error??
Hi Gurus!
I wanna know if is there any view or something like that, where I can look for a sql sentence with error?
The views V$SQL, V$SQLAREA, V$SQLTEXT doesn't work for that because they have de last rigth sql sentences and I need the last with error.
Thanks in advance.SQL Developer maintains a history of the SQL statements that it has issued over time. That is a purely client-side function, though, it just tells you what SQL has been issued by the local client. It doesn't tell you anything about what SQL has been sent to the server by other client applications on the client machine or from other client machines.
Justin -
Sorting and Grouping -Two months in this query
Hi All,
many thanks for jeneesh
i am doing project for construction company, i face this problem in grouping points according to relation between these points the
Relation is from 1 to 100. If the point between this rang that mean there is relation between these points.
this question already solve but the results not correct when the table has more data.
SQL - sorting and grouping.
from jeneesh and many thanks for him.
This example for more clarifications
for example i have these points
id location percentage comments
1 loc 1,2 20% that mean point 1 and 2 close to each other by 20%
2 loc 1,3 40% that mean point 1 and 3 close to each other byy 40%
3 Loc 8,6 25% that mean point 8 and 6 close to each other by 25%
4 Loc 6,10 20%
5 LOC 11,10 10 %
6 LOC 15,14 0%Also , we can see the relation between these points as follwoing
- points 1,2,3 in one group why becuase 1,2 has relation and 1,3 has relation that mean 1,3 also has hidden relation.
- Points 6,8,10,11 in second group there are relations between them .
- but no relation between 1 or 2 or 3 with any point of 6,8,9,10,11
- as well as no relation between 15, 14 that mean 14 in third group and 15 in fourth group.
whati need?
to group the points that has relation according to percentage value ascending
The most important part is to group the points. SO , the below query the gropuing is not correct.
I have the follwoing table with data
drop table temp_value;
create table temp_value(id number(10),location varchar2(20), percentage number(9));
insert into temp_value values (1,'LOC 1,2',10);
insert into temp_value values (2,'LOC 1,3',0);
insert into temp_value values (3,'LOC 1,4',0);
insert into temp_value values (4,'LOC 1,5',0);
insert into temp_value values (5,'LOC 1,6',0);
insert into temp_value values (6,'LOC 2,3',0);
insert into temp_value values(7,'LOC 2,4',0);
insert into temp_value values (8,'LOC 2,5',30);
insert into temp_value values (9,'LOC 2,6',0);
insert into temp_value values (10,'LOC 3,4',0);
insert into temp_value values (11,'LOC 3,5',0);
insert into temp_value values (12,'LOC 4,5',40);
insert into temp_value values (13,'LOC 4,6',0);
insert into temp_value values (14,'LOC 6,7',40);
insert into temp_value values (15,'LOC 7,2',0);
insert into temp_value values (16,'LOC 8,2',60);
insert into temp_value values (17,'LOC 8,3',0);
insert into temp_value values (18,'LOC 3,1',0);
insert into temp_value values (19,'LOC 9,6',30);
insert into temp_value values (20,'LOC 11,2',0);
insert into temp_value values (22,'LOC 12,3',10);
insert into temp_value values (23,'LOC 19,3',0);
insert into temp_value values (24,'LOC 17,3',0);
insert into temp_value values (24,'LOC 20,3',0);when i used this query , the results is not correct
with t as
(select percentage,loc1,loc2,sum(case when percentage = 0 then 1
when loc1 in (l1,l2) then 0
when loc2 in (l1,l2) then 0
when l1 is null and l2 is null then 0
else 1
end) over(order by rn) sm
from ( select id,location,percentage,
regexp_substr(location,'\d+',1,1) LOC1,
regexp_substr(location,'\d+',1,2) LOC2,
lag(regexp_substr(location,'\d+',1,1))
over(order by percentage desc) l1,
lag(regexp_substr(location,'\d+',1,2))
over(order by percentage desc) l2,
row_number() over(order by percentage desc) rn
from temp_value
order by percentage desc
select loc,min(sm)+1 grp
from(
select loc,rownum rn,sm
from(
select percentage,decode(rn,1,loc1,loc2) loc,sm
from t a,
(select 1 rn from dual union all
select 2 from dual ) b
order by percentage desc,decode(rn,1,loc1,loc2) asc
group by loc
order by min(sm),min(rn);the results
SQL> /
LOC GRP
2 1
8 1
6 2
7 2
4 3
5 3
9 4
1 5
12 6
3 6
11 13
LOC GRP
19 14
17 15
20 22
14 rows selected.SQL>
but the correct is
Location group No
2 1
8 1
4 1
5 1
1 1
6 2
7 2
9 2
12 3
3 3
19 4
17 5
20 6many thanks in advance.
Edited by: Ayham on Nov 30, 2012 3:07 AMThanks,
i want the sorting for each group DESC not all groups to gather
when i used your query i get
SQL> with connects as (
2 select distinct
3 loc1
4 ,loc2
5 ,dense_rank() over (order by connect_by_root(loc1)) grp
6 from temp_value
7 start with
8 percentage != 0
9 connect by nocycle
10 (prior loc2 = loc1
11 or
12 prior loc1 = loc2
13 or
14 prior loc1 = loc1
15 or
16 prior loc2 = loc2)
17 and
18 percentage != 0
19 )
20 , got_grp AS
21 (
22 select
23 loc
24 ,dense_rank() over (order by grp) grp
25 from (
26 select
27 loc
28 ,max(grp) keep (dense_rank first order by grp) grp
29 from (
30 select
31 loc1 loc
32 ,grp
33 from connects
34 union
35 select
36 loc2
37 ,grp
38 from connects
39 )
40 group by
41 loc
42 )
43 )
44 SELECT loc
45 , grp
46 FROM got_grp
47 ORDER BY COUNT (*) OVER (PARTITION BY grp) DESC
48 , grp
49 , loc
50 ;The output is
LOC GRP
1 1
2 1
4 1
5 1
8 1
6 3
7 3
9 3
12 2
3 2
10 rows selected.but i want it like this
Loc Grp
2 1
8 1
4 1
5 1
1 1
12 2
3 2
6 3
7 3
9 3So , the sorting for each group Separate based on the percentage column.
many thanks
Edited by: Ayham on Nov 30, 2012 9:43 AM -
I have a scenario with the three nodes with server 2012 standard, each running an instance of SQL Server 2012 enterprise, participate in a
single Windows Server Failover Cluster (WSFC) that spans two data centers.
If the nodes in the primary data center are unavailable due to data center outage. Then how I can able to access node in the WSFC (Windows Server Failover Cluster) in the secondary disaster recovery data center automatically with some script.
I want to write script that can be able to check primary data center by pinging some IP after every 5 or 10 minutes.
If that IP is unable to respond then script can be able to Perform Forced Manual Failover of Availability Group (SQL Server) and WSFC (Windows Server Failover Cluster)
Can you please guide me for script writing for automatic failover in case of primary datacenter outage?please post you question on failover clusters in the cluster forum. THey will explain how this works and point you at scipts.
You should also look in the Gallery for cluster management scripts.
¯\_(ツ)_/¯ -
I have a scenario with the three nodes with server 2012 standard, each running an instance of SQL Server 2012 enterprise, participate in a
single Windows Server Failover Cluster (WSFC) that spans two data centers.
If the nodes in the primary data center are unavailable due to data center outage. Then how I can able to access node in the WSFC (Windows Server Failover Cluster) in the secondary disaster recovery data center automatically with some script.
I want to write script that can be able to check primary data center by pinging some IP after every 5 or 10 minutes.
If that IP is unable to respond then script can be able to Perform Forced Manual Failover of Availability Group (SQL Server) and WSFC (Windows Server Failover Cluster)
Can you please guide me for script writing for automatic failover in case of primary datacenter outage?You are trying to implement manually what should be happening automatically in the cluster. If the primary SQL Server becomes unavailable in the data center, it should fail over to the secondary SQL Server automatically. Is that not working?
You also might want to run this configuration by some SQL experts. I am not a SQL expert, but if you have both hosts in the data center in a cluster, there is no need for replication between those two nodes as they would be accessing
the database from some form of shared storage. Then it looks like you are trying to implement Always On to the DR site. I'm not sure you can mix both types of failover in a single configuration.
FYI, it would make more sense to establish a file share witness in your DR site instead of placing a third node in the data center for Node Majority quorum.
. : | : . : | : . tim -
How to export data and SQL sentence?
Hi all,
I need to create SQL sentences with INSERT INTO clauses of exported data from a table to populate another table?
Thanks and best regards,
Carlos N.Inserting one row at a time is inefficient.
You can do this instead
SQL> select decode(rownum,1,'Insert all'||chr(13),' ')||
2 'into emp (empno,ename) values ('||empno||','''||ename||''')' from emp
3 /
DECODE(ROWNUM,1,'INSERTALL'||CHR(13),'')||'INTOEMP(EMPNO,ENAME)VALUES('||EMPNO||','''||ENAME||''
Insert all into emp (empno,ename) values (7369,'SMITH')
into emp (empno,ename) values (7499,'ALLEN')
into emp (empno,ename) values (7521,'WARD')
into emp (empno,ename) values (7566,'JONES')
into emp (empno,ename) values (7654,'MARTIN')
into emp (empno,ename) values (7698,'BLAKE')
into emp (empno,ename) values (7782,'CLARK')
into emp (empno,ename) values (7788,'SCOTT')
into emp (empno,ename) values (7839,'KING')
into emp (empno,ename) values (7844,'TURNER')
into emp (empno,ename) values (7876,'ADAMS')
into emp (empno,ename) values (7900,'JAMES')
into emp (empno,ename) values (7902,'FORD')
into emp (empno,ename) values (7934,'MILLER')
select * from dual ; --- // Add this statement manually or in the script
-- // using prompt statement in sqlplus SS -
SCOM 2012 R2 Management Servers and SQL Server Availability Groups
My team is in the middle of rolling out a brand new install of System Center Operations Manager 2012 R2.
I have set up a SQL Server Availability group that is spread across multiple subnets and installed the initial management server per
here.
As I have gone through attaching new management servers, I have noticed disturbing behavior. When the AG fails over to another node, the management servers will lose connectivity unless I either recycle the service or it fails back to the original
node. This is not a security issue as I have set up permissions. It says it cannot connect to the database anymore at all.
Has anyone else seen this behavior? Is there a setting I am missing somewhere?
Thanks for your help.
DaleHi Dale,
What about ApplicationIntent\Readonly?
http://msdn.microsoft.com/en-us/library/hh205662(v=vs.110).aspx
Still thinking about DNS, may be this could be for your case:
http://www.sqlservercentral.com/Forums/Topic1449216-2799-1.aspx
Natalya -
More Guru Winners for February 2015 in the T-SQL category and many others!
It's been a busy week that also saw the
TECHNET WIKI SUMMIT 2015
Then we had the results for
February's TechNet Guru competition ALSO posted!
http://blogs.technet.com/b/wikininjas/archive/2015/03/19/technet-guru-february-2015.aspx
Below is a summary of the medal winners for December. The last column being a few of the comments from the judges.
Unfortunately, runners up and their judge feedback comments had to be trimmed from THIS post, to fit into the forum's 60,000 character limit, however the full version is available on TechNet Wiki in the link above.
Some articles only just missed out, so we may be returning to discuss those too, in future blogs.
BizTalk Technical Guru - February 2015
Steef-Jan Wiggers
BizTalk Server 2013 R2 Instrumenting a custom pipeline component with ETW
Mandi Ohlinger: "Always a fan of helping our custom pipeline users. Great addition to this group."
Sandro Pereira: "Images, format, descriptions, code and topic are excellent once again good work Steef-Jan."
Vignesh Sukumar
BizTalk BAM (Business Activity Monitoring)
Sandro Pereira: "Great job on this article! Well explained and nice pictures, however the article format need to be improved and some proofreading is need"
Mandi Ohlinger: "Welcome to the 'I heart BAM' fan club. Nice job on this topic. A MUST read for new-to-BAM users. "
Steef-Jan Wiggers
BizTalk Server 2013 R2 Instrumenting BAM Activity Tracking with ETW
Sandro Pereira: "Images, format, descriptions, code and topic are excellent once again good work Steef-Jan."
Mandi Ohlinger: "ETW for BAM Activities - LOVE it. Nice use of the Framework. "
Forefront Identity Manager Technical Guru - February 2015
Wim Beck
FIM2010: Filter objects on export
PG: "Simple, targeted but nice article, nice layout. "
Søren Granfeldt: "Nice. Would be perfect with a complete code sample."
Microsoft Azure Technical Guru - February 2015
saramgsilva
Azure Mobile Services: How to see the log files in server
JH: "Log files are one of the most important things in a production environment. This article shows hows you can do that for the Azure Mobile Services in a nice and easy way."
Alan Carlos: "Great article!"
Ed Price: "Very useful topic! These are a great set of articles!"
saramgsilva
Azure Mobile Services: How to see the WebConfig file published
Ed Price: "Great detail and fantastic use of images! I love all the in-line links!"
JH: "Sometimes it is hard to tell when working in a multi-environment what configuration was published to the Server. The article shows short and easy how to do that for the Azure Mobile Services."
Miscellaneous Technical Guru - February 2015
Arleta Wanat
Retrieve all site mailboxes in your Office 365 tenant
Durval Ramos: "This article has a well content, images and code that help to understand the solution. It has References and was Translated into more two languages. Good job!"
Richard Mueller: "Good links. A great tutorial."
Andy ONeill
Silverlight: No Need to BringIntoView
Durval Ramos: "A well formatted article is easier and more pleasant to read. This script is useful"
Richard Mueller: "Good demonstration of a new feature."
Chen V
PowerShell : Enable Auto Reply for Shared Mail Box
Durval Ramos: " A good solution originated of TechNet Forum. The script and images make it easy to understand and ensure you get the best interest to reader."
Richard Mueller: "Good documentation of this feature."
SharePoint 2010 / 2013 Technical Guru - February 2015
Geetanjali Arora
SharePoint Online : Performing Batch Operations using REST API
KB: "Very well explained article on a new and much awaited feature. Although Andrew Connell already explained this topic in several posts, this article still contains added value."
Ed Price: "I love the History section. The formatting is amazing. And the References and See Also sections at the bottom are great icing on the cake. This is an important topic that's done incredibly well!"
Matthew Yarlett
Using the SpellCheck Webservice with the TinyMCE Richtext Editor and
AngularJS in Office 365
KB: "I read this article with growing interest, it contains a lot of added value. Very well and in-depth explanation. "
Ed Price: "Great scenario! Good use of images, code, detail, and References! Could possibly use a greater breakdown and explanation of the code. This article just gets more and more interesting and valuable as you read it! Great job!"
Arleta Wanat
SharePoint Online: Turn on support for multiple content types
in a list or library using Powershell
KB: "Really nice, interesting and detailed article!"
Ed Price: "The Content Types section helps explain this a lot! I also love the downloads at the end. What a fantastic resource!"
Small Basic Technical Guru - February 2015
Nonki Takahashi
Small Basic: Key Input
Michiel Van Hoorn: "Great improvement."
RZ: "Very nice explanation and examples of key input handling"
Ed Price - MSFT
Small Basic: The History of the Logo Turtle
RZ: "Turtle (Logo) was the first programming language for many, including perhaps some of the Small Basic prorammers. Nice article explaining the history."
Michiel Van Hoorn: "A nice background article and hopefull inspiration for those who want to start in robotics"
Nonki Takahashi
Small Basic: TechNet Wiki Article List
Michiel Van Hoorn: "This is great! Perfect as a local cache of the articles. "
RZ: "A good example"
SQL BI and Power BI Technical Guru - February 2015
Sylvain PONTOREAU
PowerBI API in .Net
RB: "Great walkthrough. Looking forward for the WP8 version of the app ;)"
PT: "Sylvain, very nice job with this. This is a timely topic about an emerging product that has great potential. This is a very good example of a well-written post on an interesting subject with enough information to be valuable to a
solution developer. I will personally take time to explore the Power BI API and use your examples. "
SQL Server General and Database Engine Technical Guru - February 2015
Ronen Ariely
SQL Server Books Online
AM: "Thank you for sharing this with us. It is quite informative and let us get familiar with BOL after the change from previous versins."
Ed Price: "Nice! A very helpful introduction to Books Online! It also tells my technical writer friends that their hard work is appreciated! =^)"
Durval Ramos
How to Collect Events and Errors on SQL Server
Ed Price: "Fantastic solution! A great resource that's amazingly well written with formatting, clear parameters, images, References, and a See Also section! And it even comes in Portuguese! Great article!"
AM: "Thank you for sharing this with us. A good source to learn about our SQL Server instances. "
System Center Technical Guru - February 2015
MarkusEliasson
Troubleshoot ID 32008: DPM cannot
protect this SharePoint farm...
Ed Price: "An important topic that's very clear with great formatting and a good use of an image!"
t.c.rich
Managing Priorities of Client Polices and A/V Policies in SCCM
Ed Price: "I love the descriptions, breakdown of sections, and code formatting! Great article!"
Mr X
How to copy SMSTS.log when a Task Sequence fails in SCCM
Ed Price: "A very helpful table and a good contribution to the community! Mr X again thinks of important content gaps to fill!"
Transact-SQL Technical Guru - February 2015
Saeid Hasani
T-SQL: How the Order of Elements in the ORDER BY Clause Implemented in the Output Result
Durval Ramos: "Very well structured and with examples that clarify how a T-SQL statement can change the data output order."
Richard Mueller: "Good use of Wiki guidelines and great examples."
Ronen Ariely
Free E-Books about SQL and Transact-SQL languages
Richard Mueller: "An excellent collection and a great idea."
Durval Ramos: "A good initiative. Very useful !!!"
Ricardo Lacerda
Declare Cursor (Transact-SQL) versus Window with Over - Running Totals
- Accumulated Earnings
Durval Ramos: "The "Window function" sample was well presented, but it was unclear how the chart was generated."
Richard Mueller: "A new idea that can be very useful. Grammar needs work"
Visual Basic Technical Guru - February 2015
Emiliano Musso
Genetic algorithm to solve 2D Mazes in Visual Basic
MR: "Great article! Love to see an application for AI in a simple game"
Durval Ramos: "This article is well documented with images and your code clarifying important details. It also has References, a very useful video and your project available for download in "MSDN Code" !"
Richard Mueller: "Incredible concept and code. Grammar needs work."
Paul Ishak
MultiHeadedTrackBar Control
Durval Ramos: "Very interesting article, with methods and properties well documented. Your project was available in "MSDN Code" which facilitates the understanding of solution."
Richard Mueller: "Amazing work. Extensive code but with lots of comments. Needs a TOC"
tommytwotrain
Using Trigonometry to draw graphic curves in VB.NET part 2.
MR: "Great continuation. Love the usage of the code for circle text"
Durval Ramos: "The article is interesting, but It's need to work better commenting about assemblies referenced on project and also structure your content into sections."
Richard Mueller: "Good tutorial and example code demonstrating basic concepts. Avoid first person."
Visual C# Technical Guru - February 2015
Magnus (MM8)
C#: Enumerating collections that change
Jaliya Udagedara: "Great article. Has a thorough and to the point explanation of problem and the solution with code samples. Loved it!"
Carmelo La Monica: "Very useful and exhaustive about errors at runtime in these circumstances. Congratulations"
Andy ONeill
c#: Practical Poly
Carmelo La Monica: "Fantastic artcle. Very detailed and exhaustive, congratulations ."
Jaliya Udagedara: "Definitely worth reading this. Explains somewhat advance topic along with a fundamental concept of programming. "
Wiki and Portals Technical Guru - February 2015
Durval Ramos
Wiki: Microsoft Short URLs Personalized by SXP
PG: "Nice idea, lots of potential to grow, really needs some more community attention."
Richard Mueller: "An excellent idea. Good use of Wiki guidelines."
Windows Phone and Windows Store Apps Technical Guru - February 2015
Carmelo La Monica
Windows Phone 8: control Nokia Maps (Part 3)
JH: "Part 3 of the series how to work with the Nokia maps control. As the previous articles this one contains a lot of code snippets and some pictures. Good work!"
Ed Price: "A great topic, a fantastic breakdown of sections with clear descriptions, and a nice mix of code formatting and helpful images! Another stellar article from Carmelo! Great job including the link back at the end to the portal
article!"
Windows PowerShell Technical Guru - February 2015
Richard Mueller
Document Your Active Directory Organization
Alan Carlos: "Wow! Great article, congratulations!!! Very detailed!"
Chen V: "Excellent Article - I liked return to top as well."
Ed Price: "Wow! It's like a professional whitepaper! It's a valuable topic that's done with intricate detail! I love the images, diagrams, code blocks, and it ends very well with more resources and Wiki articles! The article just keeps
digging deeper and deeper! Awesome job on this!"
DexterPOSH
PowerShell + REST API : Invoke-RestMethod Gotcha
Chen V: "Good Article. TOC might have made this more rich! "
Ed Price: "This is a good topic with some great content. It could benefit from sections and a TOC, as well as a References and See Also sections at the end. The inline links are helpful. Could "
DexterPOSH
PowerShell Trick : Search & highlight text in MS Word
Ed Price: "This is a great solution, with some helpful Q&A in the comments!"
Windows Presentation Foundation (WPF) Technical Guru - February 2015
Andy ONeill
Lookless Controls
KJ: "WPF can definitely be confusing when devs first encounter it. Like the way you break it down."
Ed Price: "Wow! Fantastic explanations that are very clear and deep! The images and code bring it to life!"
Andy ONeill
Only One Parent
KJ: "Same iwith this one, good 101 intro"
Ed Price: "Another great tip! I love the detail here as well! Those snippets help a lot!"
Andy ONeill
Bind to Current Item of Collection
KJ: "Feel like this topic has a lot of coverage out there, but it can't hurt to hammer on databinding yet one more time :) "
Ed Price: "Fantastic topic with great execution! Although these could benefit from References and See Also wiki sections at the end, the Inline links help a lot!"
Windows Server Technical Guru - February 2015
Mr X
Ping for Beginners
Mark Parris: "A good introduction with additional content."
JM: "Great article idea and an excellent article that will be useful to many, thanks for your contribution."
Philippe Levesque: "Good article that show a usefull utility for basic troubleshooting"
Richard Mueller
Active Directory: Get-ADFineGrainedPasswordPolicy Default and Extended Properties
Mark Parris: "An Interesting insight on FGPP and their extended properties."
JM: "This is a good piece of detailed information about this PowerShell cmdlet, thanks for sharing."
Philippe Levesque: "Great article ! Illustrating some cmdlet's output when a user got assigned policy versus a user with the default domain policy could be a good idea."
Richard Mueller
Active Directory: Get-ADServiceAccount Default and Extended Properties
Mark Parris: "A useful nugget of information."
JM: "More very useful information about an AD cmdlet, thanks!"
Philippe Levesque: "Good article !"
As mentioned above, runners up and comments were removed from this post, to fit into the forum's 60,000 character limit.
You will find the complete post, comments and feedback on the
main announcement post.
Please join the discussion, add a comment, or suggest future categories.
If you have not yet contributed an article for this month, and you think you can write a more useful, clever, or better produced wiki article than the winners above,
THERE'S STILL TIME! :D
Best regards,
Pete Laker
More about the TechNet Guru Awards:
TechNet Guru Competitions
#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over to
TechNet Wiki, for future generations to benefit from! You'll never get archived again, and
you could win weekly awards!
Have you got what it takes o become this month's
TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!Congrats to Saeid, Ronen, and Ricardo! Big thank you to all our contributors!
Transact-SQL Technical Guru - February 2015
Saeid Hasani
T-SQL: How the Order of Elements in the ORDER BY Clause Implemented in the Output Result
Durval Ramos: "Very well structured and with examples that clarify how a T-SQL statement can change the data output order."
Richard Mueller: "Good use of Wiki guidelines and great examples."
Ronen Ariely
Free E-Books about SQL and Transact-SQL languages
Richard Mueller: "An excellent collection and a great idea."
Durval Ramos: "A good initiative. Very useful !!!"
Ricardo Lacerda
Declare Cursor (Transact-SQL) versus Window with Over - Running Totals
- Accumulated Earnings
Durval Ramos: "The "Window function" sample was well presented, but it was unclear how the chart was generated."
Richard Mueller: "A new idea that can be very useful. Grammar needs work"
Also worth a mention were the other entries this month:
[T-SQL] Retrieve Table List with Number of Rows by
Emiliano Musso
Richard Mueller: "Short but sweet solution to basic question."
Durval Ramos: "A simple T-SQL script, but useful."
[T-SQL] Search for Missing Values within a Numerical Sequence by
Emiliano Musso
Richard Mueller: "Clever solution with good code examples."
Durval Ramos: "You need add more details about development of the idea and create a "Conclusion" section to easy understanding."
[T-SQL] Converting Multiple Rows into HTML Format single ROW by
Maheen Khizar (Bint-e-Adam)
Durval Ramos: "In some situations, It's need to consume and format HTML tags for a UI, but It's important to remember that Best Practices recommend this formatting process preferably in Presentation Layer"
Richard Mueller: "A great new idea. Some features need more explanation. Avoid first person."
Ed Price, Azure & Power BI Customer Program Manager (Blog,
Small Basic,
Wiki Ninjas,
Wiki)
Answer an interesting question?
Create a wiki article about it! -
Analysing details of SQL trace and runtime analysis for a report.
Hi,
I am trying to tune the performance of a Z ABAP report for target group export. A brief overview of what is done in the report is the retrieval of BP details present in the Target group including BP general, address, marketing attributes, person responsible and contact person details. As the target groups can be quite huge (around 6000 BPs), the report gives performance issues. I want to understand on how to analyse the details which I obtained from the run time analysis and SQL trace and on how to take it forward.
Any inputs in this regard would be helpful.
Thanks in advance,
AnushreeIn Runtime analysis Look for
ABAP - In your ABAP code
DATABASE - It shows the performance of your SELECT statements in your program.
Just check how much % it is showing for both.
Check for following in your code.
1) Avoid SELECT *
2) Clear internal tables values which are not required at the ending of program, as it saves memory
etc. -
How to change sql sentence which arrives database.
I am using ORACLE 10G,
I want to add criteria all sql sentence which come ORACLE 10G ,
how to do it ? , trigger or another system attributes
for example
if "select * from user" sql sentence come to db server, I want to change this sentence as "select * from user where mod =1"
thanksAll of my tables have "mode" column, when sql sentence come , I 'll read system_mode another database and then I read,delete,insert and update my tables according to this system_mode,
how to do this, I should block sqls , then read system_mode and finally add this criteria end of the sql sentence
thanks -
SQL AlwaysOn Availability Group modifies preferred owner node on move/failover
I have a two node Windows Server 2012 R2 failover cluster with two SQL Server 2012 Enterprise AlwaysOn Availability groups configured. Within the cluster I have configured a preference order on which node a AlwaysOn Availability Group should run.
Get-ClusterGroup -Name "AlwaysOn1" | Set-ClusterOwnerNode -Owners "node1","node2";
Get-ClusterGroup -Name "AlwaysOn2" | Set-ClusterOwnerNode -Owners "node2","node1";
After configuring the preference and retrieving the preference order it is configured as it should be. When I do a failover the preference order is adjusted to first the node it currently runs on and second the other node instead of leaving the preference
order as it was. It doesn't matter if I use the PowerShell "Move-ClusterGroup" or the "ALTER AVAILABILITY GROUP [AlwaysOn1] FAILOVER" T-SQL command. From the cluster log it is shown that the preference is modified after the resource
has been moved.
INFO [GUM] Node 2: executing request locally, gumId:15859, my action: /rcm/gum/SetGroupPreferredOwners, # of updates: 1
INFO [RCM] rcm::RcmGum::SetGroupPreferredOwners(AlwaysOn1,<vector len='2'>
The default groups within the cluster "Available Storage" and "Cluster Group" keep their preference setting when configured (only configured for testing to verify it has to do with the SQL Server Availability Group resource type).
The Windows Server 2012 R2 servers are updated using the latest Windows Updates and SQL 2012 has build number 11.0.5556.
For other cluster groups which I have configured in the past like file, Hyper-V (used for affinity to get VM's which have a lot of traffic between them within the same virtual switch to reduce latency and additional hops. it would be nice if vNext will have
a affinity option for cluster groups besides the anti-affinity within the current version)
I would like to know if someone could explain why the SQL Server Availability Group resource always modifies the group preference. I might understand this with a three node cluster where the first two are running in Synchronous commit mode and the third
one in Asynchronous commit mode.
Thanks in advance,
Dennis van den AkkerHi Dennis van den Akker,
Do not use the Failover Cluster Manager to manipulate availability groups, for example:
Do not add or remove resources in the clustered service (resource group) for the availability group.
Do not change any availability group properties, such as the possible owners and preferred owners. These properties are set automatically by the availability group.
Do not use the Failover Cluster Manager to move availability groups to different nodes or to fail over availability groups. The Failover Cluster Manager is not aware of the synchronization status of the availability replicas, and doing so can lead to extended
downtime. You must use Transact-SQL or SQL Server Management Studio.
The related KB:
Failover Clustering and AlwaysOn Availability Groups (SQL Server)
https://msdn.microsoft.com/en-us/library/ff929171.aspx
The similar thread:
SQL Server Clustering 2008 (Multi Node)
https://social.msdn.microsoft.com/Forums/sqlserver/zh-CN/c35fe863-3fed-4a6e-830b-b79aa032c198/sql-server-clustering-2008-multi-node?forum=sqldisasterrecovery
Best Regards,
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
How to learn to extract data and group it
I recently met a guy who is looking to employ some folks. He got in touch with me in LinkedIn. I have done my research and I know he’s a real guy looking for people. I would like to get the job despite of the poor work conditions but I just feel the fear of failing or not being capable to do the job.
I know I have to try and it will be great if some of you could give some advice on how to do the job or how can I self-learn this. I'm ready to read books and follow instructions. Last year, I did a DBA internship so, I’m familiar with PL/SQL but I didn’t cover information on how to programme or gather data.
Here’s bit of the job information: "The work is to programme in PL/SQL to extract data and group it. You will learn how to make indexes and work with massive data. You will learn about programming performance in PL-SQL to extract data".
I have translated the job info from Spanish to English so, I hope you can get what I’m actually looking for. For the ones that can speak Spanish, this is what the guy wrote: "El trabajo es programar en PL/SQL para extraer datos y centralizarlos. Va a aprender a realizar índices y trabajar con datos masivos. Va a aprender mucho sobre performance de programación en PL-SQL para extraer datos".
Thanks! Gracias!
Edited by: 2learnOracle on 25-Jan-2013 16:12Hi chaituatp,
For this requirement, I would suggest you to get familiar with how to create VSTO applications, and how SharePoint object model works. Here are some sample code about this:
How to: Retrieve List Items using JavaScript:
http://msdn.microsoft.com/en-us/library/hh185007(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx
VSTO application show data in datagridview:
http://stackoverflow.com/questions/16926275/simple-example-of-vsto-excel-using-a-worksheet-as-a-datasource
Thanks,
Qiao
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Qiao Wei
TechNet Community Support -
Can HTML-based reports be built in BLS via an SQL Query and XSLT?
Hello xMII experts,
I have already built a report in xMII which uses XSLT to provide group/sum totals in a web browser. However in a new project, the report must run at certain times and possibly when certain signals become true in the process.
It appears that BLS is a good choice to achieve this and my proposed Transaction was:
1. SQL Query Action(uses the same QueryTemplate as in xMII)
2. XSLTransform Action on the resulting XML resultset (The .xsl file contains HTML which is the original used in xMII to produce the report there)
3. HTML Loader action with the resulting output of the transformation
I have now got some output in the resulting HTML file - however it omits all XSLT code - and I am left with an empty HTML shell but for a few images.
This indicates that perhaps no SQL data was ever returned.
I have therefore two questions:
1. How can I check if the SQL returned data?
2. Is it possible to deliver data to a HTML file directly after an XSLTransformation.
Looking forward to your responses
Best Regards
Robert SalesThank you for the replies.
I am a little closer the result I need - however I think I need to explain what I had and what I need a little better.
Before BLS
1 xMII report page (.irpt extension) with two iCalendar applets (start/end date) and a set of buttons (1 for each report)
Upon clicking on a button the two dates are passed into an .irpt file, and via a servlet an SQL QueryTemplate and a XSL DisplayTemplate are used to build the report.
The HTML is embedded in the XSL file - thereby generating the report direct in the web browser.
- This all works fine
With BLS
A transaction which uses a modified SQL QueryTemplate (no date parameters) passing the results to an XML file. This works.
Now when I click on the button in my xMII screen the .irpt file is called with no Date parameters and the xAcute QueryTemplate called with the XSL DisplayTemplate. The irpt file has <html> and <body> tags with XSL file in the Servlet call providing the tables and data extraction from the XML.
I have no additional HTML file so I placed the iframe tag inside the XSL file - but it refers to the .irpt file - this doesn't sound right!
I do get a little output in the web browser but it still omits all XSLT code.
One more point - The Transaction can be scheduled and run as required - but I need the entire report to created and stored for viewing at a later date. Will a servlet tag running inside an .irpt file achieve this?
Sorry for the chaotic writing here - but I must leave the office.
Regards
Robert Sales
Maybe you are looking for
-
I have a KT4V and would like to install ati 9600XT. Do I need to upgrade BIOS?
I have a KT4V (MS6712) running version 1.0 BIOS (never updated). I tried an ATI Radeon 9600XT a couple of days ago. The system and display went nuts. I figured the card was DOA, but I have since reaad on this board that a newer version of the BIOS
-
How can i make factory reset to may macbook pro
hey, how can i make factory reset to my macbook pro
-
I have forgotten my pin for my iphone how do i reset it?
Hello Apple Somehow I have managed to forget passcode .Is there a way of unlocking it again ? <edited by host>
-
I just want to calculate a total
Hi, I'd like to calculate automatically total of 2 inputValues. For sure i need to set the autoSubmit="true" on both of my inputValues + partialTriggers on the TOTAL one. What I'd like to know is what is the best practise on how to hanlde the result
-
7/11/2012 - AIR 3.3 Runtime and SDK Updated
Today, the AIR 3.3 Runtimes and SDKs were updated to address the following problems: Audio issues iOS 6 GPU mode iOS native extension issues Out of memory conditions that can occur with ADT AIR 3.3.0.3670 Runtime for Windows and Macintosh AIR 3.3.0.3